Documentation
¶
Index ¶
- Variables
- type Iterator
- type Slice
- func (ss *Slice) Append(vals ...interface{})
- func (ss *Slice) AppendTo(oss *Slice) *Slice
- func (ss *Slice) Cap() int
- func (ss *Slice) Copy() *Slice
- func (ss *Slice) ForEach(fn func(i int, v interface{}) (breakNow bool)) bool
- func (ss *Slice) ForEachAt(i int, fn func(i int, v interface{}) (breakNow bool)) bool
- func (ss *Slice) Get(i int) interface{}
- func (ss *Slice) GoString() string
- func (ss *Slice) Grow(sz int) int
- func (ss *Slice) Iter() *Iterator
- func (ss *Slice) IterAt(start, end int) *Iterator
- func (ss *Slice) Len() int
- func (ss *Slice) Less(i, j int) bool
- func (ss *Slice) MarshalJSON() ([]byte, error)
- func (ss *Slice) Pop() (v interface{})
- func (ss *Slice) Segments() int
- func (ss *Slice) Set(i int, v interface{})
- func (ss *Slice) SetUnmarshalType(val interface{})
- func (ss *Slice) Slice(start, end int) *Slice
- func (ss *Slice) String() string
- func (ss *Slice) Swap(i, j int)
- func (ss *Slice) UnmarshalJSON(b []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
var DefaultSegmentLen = 128
DefaultSegmentLen is used if segLen is 0, mostly during an auto-constructed slice from JSON.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is a SegmentedSlice iterator.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice is a special slice-of-slices, when it grows it creates a new internal slice rather than growing and copying data.
func New ¶
New returns a new Slice with the specified segment length. Length must be a power of two or 0, if it is 0 it will use the DefaultSegmentLen.
func NewSortable ¶
NewSortable returns a Slice that supports the sort.Interface Length must be a power of two or 0, if it is 0 it will use the DefaultSegmentLen.
func (*Slice) Append ¶
func (ss *Slice) Append(vals ...interface{})
Append appends vals to the slice. If used on a sub-slice, it turns into an independent slice.
func (*Slice) AppendTo ¶
AppendTo appends all the data in the current slice to `other` and returns `other`.
func (*Slice) Copy ¶
Copy returns an exact copy of the slice that could be used independently. Copy is internally used if you call Append, Pop or Grow on a sub-slice.
func (*Slice) ForEachAt ¶
ForEachAt loops over the slice and calls fn for each element. If fn returns true, it breaks early and returns true otherwise returns false.
func (*Slice) Grow ¶
Grow grows internal data structure to fit `sz` amount of new items. If used on a sub-slice, it turns into an independent slice.
func (*Slice) IterAt ¶
IterAt returns an Iterator object Example:
for it := ss.IterAt(0, ss.Len()); it.More(); { log.Println(it.Next()) }
func (*Slice) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Slice) Pop ¶
func (ss *Slice) Pop() (v interface{})
Pop deletes and returns the last item in the slice. If used on a sub-slice, it turns into an independent slice.
func (*Slice) SetUnmarshalType ¶
func (ss *Slice) SetUnmarshalType(val interface{})
SetUnmarshalType sets the internal type used for UnmarshalJSON. Example:
ss.SetUnmarshalType(&DataStruct{}) ss.SetUnmarshalType(reflect.TypeOf(&DataStruct{}))
func (*Slice) Slice ¶
Slice returns a sub-slice, the equivalent of ss[start:end], modifying any data in the returned slice modifies the parent.
func (*Slice) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler