Package vector
import "container/vector"
The vector package implements containers for managing sequences of elements. Vectors grow and shrink dynamically as necessary.
Package files
defs.go intvector.go stringvector.go vector.gotype IntVector
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.
type IntVector []int
func (*IntVector) AppendVector
func (p *IntVector) AppendVector(x *IntVector)
AppendVector appends the entire vector x to the end of this vector.
func (*IntVector) At
func (p *IntVector) At(i int) int
At returns the i'th element of the vector.
func (*IntVector) Cap
func (p *IntVector) 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 (*IntVector) Cut
func (p *IntVector) Cut(i, j int)
Cut deletes elements i through j-1, inclusive.
func (*IntVector) Data
func (p *IntVector) Data() []int
Data returns all the elements as a slice.
func (*IntVector) Delete
func (p *IntVector) 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 (*IntVector) Do
func (p *IntVector) 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 (*IntVector) Expand
func (p *IntVector) Expand(i, n int)
Insert n elements at position i.
func (*IntVector) Extend
func (p *IntVector) Extend(n int)
Insert n elements at the end of a vector.
func (*IntVector) Insert
func (p *IntVector) Insert(i int, x int)
Insert inserts into the vector an element of value x before the current element at index i.
func (*IntVector) InsertVector
func (p *IntVector) InsertVector(i int, x *IntVector)
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) Iter
func (p *IntVector) Iter() <-chan int
Channel iterator for range.
func (*IntVector) Last
func (p *IntVector) Last() int
Last returns the element in the vector of highest index.
func (*IntVector) Len
func (p *IntVector) Len() int
Len returns the number of elements in the vector. Same as len(*p).
func (*IntVector) Less
func (p *IntVector) Less(i, j int) bool
Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (*IntVector) Pop
func (p *IntVector) Pop() int
Pop deletes the last element of the vector.
func (*IntVector) Push
func (p *IntVector) Push(x int)
Push appends x to the end of the vector.
func (*IntVector) Resize
func (p *IntVector) Resize(length, capacity int) *IntVector
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 (*IntVector) Set
func (p *IntVector) Set(i int, x int)
Set sets the i'th element of the vector to value x.
func (*IntVector) Slice
func (p *IntVector) Slice(i, j int) *IntVector
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 (*IntVector) Swap
func (p *IntVector) Swap(i, j int)
Swap exchanges the elements at indexes i and j.
type LessInterface
LessInterface provides partial support of the sort.Interface.
type LessInterface interface {
Less(y interface{}) bool
}
type StringVector
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.
type StringVector []string
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) Cut
func (p *StringVector) Cut(i, j int)
Cut deletes elements i through j-1, inclusive.
func (*StringVector) Data
func (p *StringVector) Data() []string
Data returns all the elements as a slice.
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 interface{}))
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) Iter
func (p *StringVector) Iter() <-chan string
Channel iterator for range.
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
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.
type Vector []interface{}
func (*Vector) AppendVector
func (p *Vector) AppendVector(x *Vector)
AppendVector appends the entire vector x to the end of this vector.
func (*Vector) At
func (p *Vector) At(i int) interface{}
At returns the i'th element of the vector.
func (*Vector) Cap
func (p *Vector) 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 (*Vector) Cut
func (p *Vector) Cut(i, j int)
Cut deletes elements i through j-1, inclusive.
func (*Vector) Data
func (p *Vector) Data() []interface{}
Data returns all the elements as a slice.
func (*Vector) Delete
func (p *Vector) 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 (*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) Expand
func (p *Vector) Expand(i, n int)
Insert n elements at position i.
func (*Vector) Extend
func (p *Vector) Extend(n int)
Insert n elements at the end of a vector.
func (*Vector) Insert
func (p *Vector) Insert(i int, x interface{})
Insert inserts into the vector an element of value x before the current element at index i.
func (*Vector) InsertVector
func (p *Vector) InsertVector(i int, x *Vector)
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) Iter
func (p *Vector) Iter() <-chan interface{}
Channel iterator for range.
func (*Vector) Last
func (p *Vector) Last() interface{}
Last returns the element in the vector of highest index.
func (*Vector) Len
func (p *Vector) Len() int
Len returns the number of elements in the vector. Same as len(*p).
func (*Vector) Less
func (p *Vector) Less(i, j int) bool
Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (*Vector) Pop
func (p *Vector) Pop() interface{}
Pop deletes the last element of the vector.
func (*Vector) Push
func (p *Vector) Push(x interface{})
Push appends x to the end of the vector.
func (*Vector) Resize
func (p *Vector) Resize(length, capacity int) *Vector
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 (*Vector) Set
func (p *Vector) Set(i int, x interface{})
Set sets the i'th element of the vector to value x.
func (*Vector) Slice
func (p *Vector) Slice(i, j int) *Vector
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 (*Vector) Swap
func (p *Vector) Swap(i, j int)
Swap exchanges the elements at indexes i and j.
