Documentation ¶
Overview ¶
Package vector implements containers for managing sequences of elements. Vectors grow and shrink dynamically as necessary.
Index ¶
- type IntVector
- func (p *IntVector) AppendVector(x *IntVector)
- func (p *IntVector) At(i int) int
- func (p *IntVector) Cap() int
- func (p *IntVector) Copy() IntVector
- func (p *IntVector) Cut(i, j int)
- func (p *IntVector) Delete(i int)
- func (p *IntVector) Do(f func(elem int))
- func (p *IntVector) Expand(i, n int)
- func (p *IntVector) Extend(n int)
- func (p *IntVector) Insert(i int, x int)
- func (p *IntVector) InsertVector(i int, x *IntVector)
- func (p *IntVector) Last() int
- func (p *IntVector) Len() int
- func (p *IntVector) Less(i, j int) bool
- func (p *IntVector) Pop() int
- func (p *IntVector) Push(x int)
- func (p *IntVector) Resize(length, capacity int) *IntVector
- func (p *IntVector) Set(i int, x int)
- func (p *IntVector) Slice(i, j int) *IntVector
- func (p *IntVector) Swap(i, j int)
- type LessInterface
- type StringVector
- func (p *StringVector) AppendVector(x *StringVector)
- func (p *StringVector) At(i int) string
- func (p *StringVector) Cap() int
- func (p *StringVector) Copy() StringVector
- func (p *StringVector) Cut(i, j int)
- func (p *StringVector) Delete(i int)
- func (p *StringVector) Do(f func(elem string))
- func (p *StringVector) Expand(i, n int)
- func (p *StringVector) Extend(n int)
- func (p *StringVector) Insert(i int, x string)
- func (p *StringVector) InsertVector(i int, x *StringVector)
- func (p *StringVector) Last() string
- func (p *StringVector) Len() int
- func (p *StringVector) Less(i, j int) bool
- func (p *StringVector) Pop() string
- func (p *StringVector) Push(x string)
- func (p *StringVector) Resize(length, capacity int) *StringVector
- func (p *StringVector) Set(i int, x string)
- func (p *StringVector) Slice(i, j int) *StringVector
- func (p *StringVector) Swap(i, j int)
- type Vector
- func (p *Vector) AppendVector(x *Vector)
- func (p *Vector) At(i int) interface{}
- func (p *Vector) Cap() int
- func (p *Vector) Copy() Vector
- func (p *Vector) Cut(i, j int)
- func (p *Vector) Delete(i int)
- func (p *Vector) Do(f func(elem interface{}))
- func (p *Vector) Expand(i, n int)
- func (p *Vector) Extend(n int)
- func (p *Vector) Insert(i int, x interface{})
- func (p *Vector) InsertVector(i int, x *Vector)
- func (p *Vector) Last() interface{}
- func (p *Vector) Len() int
- func (p *Vector) Less(i, j int) bool
- func (p *Vector) Pop() interface{}
- func (p *Vector) Push(x interface{})
- func (p *Vector) Resize(length, capacity int) *Vector
- func (p *Vector) Set(i int, x interface{})
- func (p *Vector) Slice(i, j int) *Vector
- func (p *Vector) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntVector ¶
type IntVector []int
IntVector is a container for numbered sequences of elements of type int. A vector's length and capacity adjusts automatically as necessary. The zero value for IntVector is an empty vector ready to use.
func (*IntVector) AppendVector ¶
AppendVector appends the entire vector x to the end of this vector.
func (*IntVector) Cap ¶
Cap returns the capacity of the vector; that is, the maximum length the vector can grow without resizing. Same as cap(*p).
func (*IntVector) Delete ¶
Delete deletes the i'th element of the vector. The gap is closed so the old element at index i+1 has index i afterwards.
func (*IntVector) Do ¶
Do calls function f for each element of the vector, in order. The behavior of Do is undefined if f changes *p.
func (*IntVector) Insert ¶
Insert inserts into the vector an element of value x before the current element at index i.
func (*IntVector) InsertVector ¶
InsertVector inserts into the vector the contents of the vector x such that the 0th element of x appears at index i after insertion.
func (*IntVector) Less ¶
Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (*IntVector) Resize ¶
Resize changes the length and capacity of a vector. If the new length is shorter than the current length, Resize discards trailing elements. If the new length is longer than the current length, Resize adds the respective zero values for the additional elements. The capacity parameter is ignored unless the new length or capacity is longer than the current capacity. The resized vector's capacity may be larger than the requested capacity.
type LessInterface ¶
type LessInterface interface {
Less(y interface{}) bool
}
LessInterface provides partial support of the sort.Interface.
type StringVector ¶
type StringVector []string
StringVector is a container for numbered sequences of elements of type string. A vector's length and capacity adjusts automatically as necessary. The zero value for StringVector is an empty vector ready to use.
func (*StringVector) AppendVector ¶
func (p *StringVector) AppendVector(x *StringVector)
AppendVector appends the entire vector x to the end of this vector.
func (*StringVector) At ¶
func (p *StringVector) At(i int) string
At returns the i'th element of the vector.
func (*StringVector) Cap ¶
func (p *StringVector) Cap() int
Cap returns the capacity of the vector; that is, the maximum length the vector can grow without resizing. Same as cap(*p).
func (*StringVector) Copy ¶
func (p *StringVector) Copy() StringVector
Copy makes a copy of the vector and returns it.
func (*StringVector) Cut ¶
func (p *StringVector) Cut(i, j int)
Cut deletes elements i through j-1, inclusive.
func (*StringVector) Delete ¶
func (p *StringVector) Delete(i int)
Delete deletes the i'th element of the vector. The gap is closed so the old element at index i+1 has index i afterwards.
func (*StringVector) Do ¶
func (p *StringVector) Do(f func(elem string))
Do calls function f for each element of the vector, in order. The behavior of Do is undefined if f changes *p.
func (*StringVector) Expand ¶
func (p *StringVector) Expand(i, n int)
Insert n elements at position i.
func (*StringVector) Extend ¶
func (p *StringVector) Extend(n int)
Insert n elements at the end of a vector.
func (*StringVector) Insert ¶
func (p *StringVector) Insert(i int, x string)
Insert inserts into the vector an element of value x before the current element at index i.
func (*StringVector) InsertVector ¶
func (p *StringVector) InsertVector(i int, x *StringVector)
InsertVector inserts into the vector the contents of the vector x such that the 0th element of x appears at index i after insertion.
func (*StringVector) Last ¶
func (p *StringVector) Last() string
Last returns the element in the vector of highest index.
func (*StringVector) Len ¶
func (p *StringVector) Len() int
Len returns the number of elements in the vector. Same as len(*p).
func (*StringVector) Less ¶
func (p *StringVector) Less(i, j int) bool
Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (*StringVector) Pop ¶
func (p *StringVector) Pop() string
Pop deletes the last element of the vector.
func (*StringVector) Push ¶
func (p *StringVector) Push(x string)
Push appends x to the end of the vector.
func (*StringVector) Resize ¶
func (p *StringVector) Resize(length, capacity int) *StringVector
Resize changes the length and capacity of a vector. If the new length is shorter than the current length, Resize discards trailing elements. If the new length is longer than the current length, Resize adds the respective zero values for the additional elements. The capacity parameter is ignored unless the new length or capacity is longer than the current capacity. The resized vector's capacity may be larger than the requested capacity.
func (*StringVector) Set ¶
func (p *StringVector) Set(i int, x string)
Set sets the i'th element of the vector to value x.
func (*StringVector) Slice ¶
func (p *StringVector) Slice(i, j int) *StringVector
Slice returns a new sub-vector by slicing the old one to extract slice [i:j]. The elements are copied. The original vector is unchanged.
func (*StringVector) Swap ¶
func (p *StringVector) Swap(i, j int)
Swap exchanges the elements at indexes i and j.
type Vector ¶
type Vector []interface{}
Vector is a container for numbered sequences of elements of type interface{}. A vector's length and capacity adjusts automatically as necessary. The zero value for Vector is an empty vector ready to use.
func (*Vector) AppendVector ¶
AppendVector appends the entire vector x to the end of this vector.
func (*Vector) Cap ¶
Cap returns the capacity of the vector; that is, the maximum length the vector can grow without resizing. Same as cap(*p).
func (*Vector) Delete ¶
Delete deletes the i'th element of the vector. The gap is closed so the old element at index i+1 has index i afterwards.
func (*Vector) Do ¶
func (p *Vector) Do(f func(elem interface{}))
Do calls function f for each element of the vector, in order. The behavior of Do is undefined if f changes *p.
func (*Vector) Insert ¶
Insert inserts into the vector an element of value x before the current element at index i.
func (*Vector) InsertVector ¶
InsertVector inserts into the vector the contents of the vector x such that the 0th element of x appears at index i after insertion.
func (*Vector) Last ¶
func (p *Vector) Last() interface{}
Last returns the element in the vector of highest index.
func (*Vector) Less ¶
Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (*Vector) Resize ¶
Resize changes the length and capacity of a vector. If the new length is shorter than the current length, Resize discards trailing elements. If the new length is longer than the current length, Resize adds the respective zero values for the additional elements. The capacity parameter is ignored unless the new length or capacity is longer than the current capacity. The resized vector's capacity may be larger than the requested capacity.