Created
July 25, 2012 16:15
-
-
Save valtyriel/3177024 to your computer and use it in GitHub Desktop.
Implementation of a deque: A doubly-linked list where items can be added or removed from either end of the list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package deque | |
// A single element of the deque. | |
// The leftmost element has left = nil, | |
// and the rightmost element has right = nil. | |
type element struct{ | |
// The elements to the left and right of this one. | |
left, right *element | |
// The deque to which this element belongs. | |
deque *Deque | |
// The actual value contained in this element. | |
value interface{} | |
} | |
// Deque represents a doubly-linked list. | |
type Deque struct { | |
left, right *element | |
len int | |
} | |
// Init initializes or clears a deque. | |
func (d *Deque) Init() Deque{ | |
} | |
func (d *Deque) PushLeft(v interface{}) { | |
} | |
func (d *Deque) PushRight(v interface{}) { | |
} | |
func (d *Deque) PopLeft() interface{} { | |
} | |
func (d *Deque) PopRight() interface{} { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment