Documentation ¶
Overview ¶
Package collection implements collection types as UniqueStrings
Index ¶
- type UniqueStrings
- func (col *UniqueStrings) Add(s string) int
- func (col *UniqueStrings) AddSlice(astr []string)
- func (col *UniqueStrings) Contains(s string) bool
- func (col *UniqueStrings) Index(s string) (int, bool)
- func (col *UniqueStrings) Len() int
- func (col *UniqueStrings) Sort()
- func (col *UniqueStrings) ToSlice() []string
- func (col *UniqueStrings) Value(i int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UniqueStrings ¶
type UniqueStrings struct {
// contains filtered or unexported fields
}
UniqueStrings is a collection of distinct strings.
func NewUniqueStrings ¶
func NewUniqueStrings() *UniqueStrings
NewUniqueStrings return a new empty UniqueStrings collection.
func (*UniqueStrings) Add ¶
func (col *UniqueStrings) Add(s string) int
Add method adds the given string to the collection, if not already present. New strings are added at the end of the collection. Returns the item's position.
func (*UniqueStrings) AddSlice ¶
func (col *UniqueStrings) AddSlice(astr []string)
AddSlice adds all element of the slice to the collection.
func (*UniqueStrings) Contains ¶
func (col *UniqueStrings) Contains(s string) bool
Contains returns whether the given item is in the collection.
func (*UniqueStrings) Index ¶
func (col *UniqueStrings) Index(s string) (int, bool)
Index returns the position of the given element in the collection.
func (*UniqueStrings) Len ¶
func (col *UniqueStrings) Len() int
Len returns the number of elements of the collection.
func (*UniqueStrings) ToSlice ¶
func (col *UniqueStrings) ToSlice() []string
ToSlice returns the collection items as a slice.
func (*UniqueStrings) Value ¶
func (col *UniqueStrings) Value(i int) string
Value returns the element of the given position in the collection. if i<0 or i>=col.Len(), panic with "index out of range" runtime error.