...
1
16
17 package value
18
19 type listUnstructured []interface{}
20
21 func (l listUnstructured) Length() int {
22 return len(l)
23 }
24
25 func (l listUnstructured) At(i int) Value {
26 return NewValueInterface(l[i])
27 }
28
29 func (l listUnstructured) AtUsing(a Allocator, i int) Value {
30 return a.allocValueUnstructured().reuse(l[i])
31 }
32
33 func (l listUnstructured) Equals(other List) bool {
34 return l.EqualsUsing(HeapAllocator, other)
35 }
36
37 func (l listUnstructured) EqualsUsing(a Allocator, other List) bool {
38 return ListEqualsUsing(a, &l, other)
39 }
40
41 func (l listUnstructured) Range() ListRange {
42 return l.RangeUsing(HeapAllocator)
43 }
44
45 func (l listUnstructured) RangeUsing(a Allocator) ListRange {
46 if len(l) == 0 {
47 return EmptyRange
48 }
49 r := a.allocListUnstructuredRange()
50 r.list = l
51 r.i = -1
52 return r
53 }
54
55 type listUnstructuredRange struct {
56 list listUnstructured
57 vv *valueUnstructured
58 i int
59 }
60
61 func (r *listUnstructuredRange) Next() bool {
62 r.i += 1
63 return r.i < len(r.list)
64 }
65
66 func (r *listUnstructuredRange) Item() (index int, value Value) {
67 if r.i < 0 {
68 panic("Item() called before first calling Next()")
69 }
70 if r.i >= len(r.list) {
71 panic("Item() called on ListRange with no more items")
72 }
73 return r.i, r.vv.reuse(r.list[r.i])
74 }
75
View as plain text