Documentation
¶
Index ¶
- type BoundsError
- 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() (out Cursor[T])
- 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 BoundsError ¶ added in v0.7.0
type BoundsError struct {
// contains filtered or unexported fields
}
func (*BoundsError) Error ¶ added in v0.7.0
func (b *BoundsError) Error() string
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", 32); 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 ¶
cur := exampleSlice.Cursor()
v, err := cur.Seek(1337)
if err != nil {
fmt.Println("index is missing")
return
}
fmt.Println("My seek value!", v)
for err == nil {
v, err = cur.Next()
fmt.Println("My next value!", v)
}
Example (Prev) ¶
cur := exampleSlice.Cursor()
v, err := cur.Seek(1337)
if err != nil {
fmt.Println("index is missing")
return
}
fmt.Println("My seek value!", v)
for err == nil {
v, err = cur.Prev()
fmt.Println("My previous value!", v)
}
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 {
// Missing entry 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.