Commit 858434e3 authored by Jan Mercl's avatar Jan Mercl

Restore First/Last.

parent 2d6fbbb4
...@@ -363,15 +363,15 @@ func (t *Tree) find(q interface{}, k interface{} /*K*/) (i int, ok bool) { ...@@ -363,15 +363,15 @@ func (t *Tree) find(q interface{}, k interface{} /*K*/) (i int, ok bool) {
return l, false return l, false
} }
//A // First returns the first item of the tree in the key collating order, or // First returns the first item of the tree in the key collating order, or
//A // (zero-value, zero-value) if the tree is empty. // (zero-value, zero-value) if the tree is empty.
//A func (t *Tree) First() (k interface{} /*K*/, v interface{} /*V*/) { func (t *Tree) First() (k interface{} /*K*/, v interface{} /*V*/) {
//A if q := t.first; q != nil { if q := t.first; q != nil {
//A q := &q.d[0] q := &q.d[0]
//A k, v = q.k, q.v k, v = q.k, q.v
//A } }
//A return return
//A } }
// Get returns the value associated with k and true if it exists. Otherwise Get // Get returns the value associated with k and true if it exists. Otherwise Get
// returns (zero-value, false). // returns (zero-value, false).
...@@ -414,15 +414,15 @@ func (t *Tree) insert(q *d, i int, k interface{} /*K*/, v interface{} /*V*/) *d ...@@ -414,15 +414,15 @@ func (t *Tree) insert(q *d, i int, k interface{} /*K*/, v interface{} /*V*/) *d
return q return q
} }
//A // Last returns the last item of the tree in the key collating order, or // Last returns the last item of the tree in the key collating order, or
//A // (zero-value, zero-value) if the tree is empty. // (zero-value, zero-value) if the tree is empty.
//A func (t *Tree) Last() (k interface{} /*K*/, v interface{} /*V*/) { func (t *Tree) Last() (k interface{} /*K*/, v interface{} /*V*/) {
//A if q := t.last; q != nil { if q := t.last; q != nil {
//A q := &q.d[q.c-1] q := &q.d[q.c-1]
//A k, v = q.k, q.v k, v = q.k, q.v
//A } }
//A return return
//A } }
// Len returns the number of items in the tree. // Len returns the number of items in the tree.
func (t *Tree) Len() int { func (t *Tree) Len() int {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment