A type-safe and thread-safe array type in Go. If you are tired of slices and the Go list.list is not powerful enough for you, than you are at the right place.
Custom types should be always registred first.
Registry functions:
GetTypeName(value interface{}) string IsTypeRegistered(typeName string) boolRegisterType(value interface{})RegisteredTypes() []stringTypes:
type Element interface{}
type Array struct {
// contains filtered or unexported fields
}Array constructor:
ArrayOfType(typeName string) *ArrayArray methods:
SetType(typeName string) *ArrayType() stringAppend(newElement Element)InsertAtIndex(newElement Element, index int)RemoveAtIndex(index int) ElementRemove(element Element)RemoveFirst() ElementRemoveLast() ElementRemoveAll()Count() intIsEmpty() boolContainsElement(element Element) boolIndexForElement(element Element) intElementAtIndex(index int) Element FirstElement() ElementLastElement() Element SetAtIndex(element Element, index int)String() stringTODO-List:
- more examples
- deeper explanation
- delegation callbacks (to make the array observable)
- code enhancement
BSD license. See the LICENSE file for details.