Documentation
¶
Index ¶
- type Cursor
- type Slice
- func (s *Slice[T]) Append(t T) (err error)
- func (s *Slice[T]) Close() (err error)
- func (s *Slice[T]) Cursor(fn func(*Cursor[T]) error) (err error)
- func (s *Slice[T]) ForEach(fn func(T) (end bool)) (ended bool)
- func (s *Slice[T]) Get(index int) (kv T, err error)
- func (s *Slice[T]) InsertAt(index int, value T) (err error)
- func (s *Slice[T]) Len() int
- func (s *Slice[T]) RemoveAt(index int) (err error)
- func (s *Slice[T]) Set(index int, t T) (err error)
- func (s *Slice[T]) Slice() (out []T)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶ added in v0.2.2
type Cursor[T any] struct { // contains filtered or unexported fields }
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
func New ¶
Example ¶
var err error
if exampleSlice, err = New[int]("myfile.bat"); err != nil {
// Handle error here
return
}
func (*Slice[T]) Append ¶
Example ¶
var err error
if err = exampleSlice.Append(1337); err != nil {
// Handle error here
return
}
func (*Slice[T]) Cursor ¶ added in v0.2.2
Example ¶
err := exampleSlice.Cursor(func(c *Cursor[int]) (err error) {
v, ok := c.Seek(1337)
if !ok {
return fmt.Errorf("index is missing")
}
fmt.Println("My seek value!", v)
for ok {
v, ok = c.Next()
fmt.Println("My next value!", v)
}
return
})
if err != nil {
// Handle error here
}
Example (Prev) ¶
err := exampleSlice.Cursor(func(c *Cursor[int]) (err error) {
v, ok := c.Seek(1337)
if !ok {
return fmt.Errorf("index is missing")
}
fmt.Println("My seek value!", v)
for ok {
v, ok = c.Prev()
fmt.Println("My previous value!", v)
}
return
})
if err != nil {
// Handle error here
}
func (*Slice[T]) ForEach ¶
Example ¶
exampleSlice.ForEach(func(v int) (end bool) {
fmt.Println("Value", v)
return
})
func (*Slice[T]) Get ¶
Example ¶
var (
v int
err error
)
if v, err = exampleSlice.Get(0); err != nil {
// Handle error here
return
}
fmt.Println("Value", v)
func (*Slice[T]) InsertAt ¶
Example ¶
var err error
if err = exampleSlice.InsertAt(0, 1337); err != nil {
// Handle error here
return
}
func (*Slice[T]) RemoveAt ¶
Example ¶
var err error
if err = exampleSlice.RemoveAt(0); err != nil {
// Handle error here
return
}
Click to show internal directories.
Click to hide internal directories.