Documentation ¶
Overview ¶
Example ¶
// Create a new list and put some numbers in it. l := New() e4 := l.PushBack(4) e1 := l.PushFront(1) l.InsertBefore(3, e4) l.InsertAfter(2, e1) // Iterate through list and print its contents. for e, p := l.Front(); e != nil; e, p = e.Next(p), e { fmt.Println(e.Value) }
Output: 1 2 3 4
Index ¶
- func OutputElem(e *XorElement)
- func OutputList(l *XorList)
- func OutputListR(l *XorList)
- type XorElement
- type XorList
- func (l *XorList) Back() (back, tail *XorElement)
- func (l *XorList) Front() (front, head *XorElement)
- func (l *XorList) Init() *XorList
- func (l *XorList) InsertAfter(v interface{}, mark *XorElement) *XorElement
- func (l *XorList) InsertBefore(v interface{}, mark *XorElement) *XorElement
- func (l *XorList) Len() int
- func (l *XorList) MoveAfter(e, mark *XorElement)
- func (l *XorList) MoveBefore(e, mark *XorElement)
- func (l *XorList) MoveToBack(e *XorElement)
- func (l *XorList) MoveToFront(e *XorElement)
- func (l *XorList) Output()
- func (l *XorList) PushBack(v interface{}) *XorElement
- func (l *XorList) PushBackList(other *XorList)
- func (l *XorList) PushFront(v interface{}) *XorElement
- func (l *XorList) PushFrontList(other *XorList)
- func (l *XorList) Remove(e *XorElement) interface{}
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OutputElem ¶
func OutputElem(e *XorElement)
func OutputListR ¶
func OutputListR(l *XorList)
Iterate through list and print its contents in reverse.
Types ¶
type XorElement ¶
type XorElement struct { // Compute the bitwise XOR of this element's previous // element's address and its next element's address // and @PN stores the result PN uintptr // The value stored with this element. Value interface{} }
XorElement is an element of a xor-linked list.
func (*XorElement) Next ¶
func (e *XorElement) Next(prev *XorElement) *XorElement
Next returns the next list element or nil.
func (*XorElement) Prev ¶
func (e *XorElement) Prev(next *XorElement) *XorElement
Prev returns the previous list element or nil.
type XorList ¶
type XorList struct {
// contains filtered or unexported fields
}
XorList represents a doubly linked list. The zero value for XorList is an empty list ready to use.
func (*XorList) Back ¶
func (l *XorList) Back() (back, tail *XorElement)
Back returns the last element of list l or nil.
func (*XorList) Front ¶
func (l *XorList) Front() (front, head *XorElement)
Front returns the first element of list l or nil.
func (*XorList) InsertAfter ¶
func (l *XorList) InsertAfter(v interface{}, mark *XorElement) *XorElement
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified.
func (*XorList) InsertBefore ¶
func (l *XorList) InsertBefore(v interface{}, mark *XorElement) *XorElement
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified.
func (*XorList) MoveAfter ¶
func (l *XorList) MoveAfter(e, mark *XorElement)
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified.
func (*XorList) MoveBefore ¶
func (l *XorList) MoveBefore(e, mark *XorElement)
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified.
func (*XorList) MoveToBack ¶
func (l *XorList) MoveToBack(e *XorElement)
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified.
func (*XorList) MoveToFront ¶
func (l *XorList) MoveToFront(e *XorElement)
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified.
func (*XorList) PushBack ¶
func (l *XorList) PushBack(v interface{}) *XorElement
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*XorList) PushBackList ¶
PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same.
func (*XorList) PushFront ¶
func (l *XorList) PushFront(v interface{}) *XorElement
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*XorList) PushFrontList ¶
PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same.
func (*XorList) Remove ¶
func (l *XorList) Remove(e *XorElement) interface{}
Remove removes e from l if e is an element of list l. It returns the element value e.Value.