Documentation ¶
Index ¶
- type Cyclist
- func (l *Cyclist[T]) As(reverse ...bool) (res []T)
- func (l *Cyclist[T]) Capacity() int
- func (l *Cyclist[T]) Do(f func(T))
- func (l *Cyclist[T]) Len() int
- func (l *Cyclist[T]) Move(n int) (res []T)
- func (l *Cyclist[T]) Next(n int) []T
- func (l *Cyclist[T]) Prev(n int) []T
- func (l *Cyclist[T]) Put(s ...T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cyclist ¶
type Cyclist[T any] struct { // contains filtered or unexported fields }
Cyclist[T] A Cyclist is an element of a circular list like container/ring in standard library but based on slice.
func (*Cyclist[T]) Do ¶
func (l *Cyclist[T]) Do(f func(T))
Do calls function f on each element of the cyclist, in forward order.
func (*Cyclist[T]) Len ¶
Len computes the number of elements in cyclist l. It executes in time proportional to the number of elements.
func (*Cyclist[T]) Move ¶
Move moves n % l.Len() elements backward (n < 0) or forward (n >= 0) in the cyclist and returns that ring element.
Click to show internal directories.
Click to hide internal directories.