Added Flex.GetItem() and Flex.GetItemCount(). Resolves #385, resolves #657.

This commit is contained in:
Oliver 2021-11-08 16:13:18 +01:00
parent a4acb08f51
commit 0c92c2a810
1 changed files with 13 additions and 0 deletions

13
flex.go
View File

@ -105,6 +105,19 @@ func (f *Flex) RemoveItem(p Primitive) *Flex {
return f
}
// GetItemCount returns the number of items in this container.
func (f *Flex) GetItemCount() int {
return len(f.items)
}
// GetItem returns the primitive at the given index, starting with 0 for the
// first primitive in this container.
//
// This function will panic for out of range indices.
func (f *Flex) GetItem(index int) Primitive {
return f.items[index].Item
}
// Clear removes all items from the container.
func (f *Flex) Clear() *Flex {
f.items = nil