Documentation ¶
Index ¶
- Constants
- Variables
- type Deque
- func (d *Deque[T]) At(pos int) T
- func (d *Deque[T]) Back() T
- func (d *Deque[T]) Begin() *DequeIterator[T]
- func (d *Deque[T]) Clear()
- func (d *Deque[T]) Empty() bool
- func (d *Deque[T]) End() *DequeIterator[T]
- func (d *Deque[T]) EraseAt(pos int)
- func (d *Deque[T]) EraseRange(firstPos, lastPos int)
- func (d *Deque[T]) First() *DequeIterator[T]
- func (d *Deque[T]) Front() T
- func (d *Deque[T]) Insert(pos int, value T)
- func (d *Deque[T]) IterAt(pos int) *DequeIterator[T]
- func (d *Deque[T]) Last() *DequeIterator[T]
- func (d *Deque[T]) PopBack() T
- func (d *Deque[T]) PopFront() T
- func (d *Deque[T]) PushBack(value T)
- func (d *Deque[T]) PushFront(value T)
- func (d *Deque[T]) Set(pos int, val T) error
- func (d *Deque[T]) Size() int
- func (d *Deque[T]) String() string
- type DequeIterator
- func (iter *DequeIterator[T]) Clone() iterator.ConstIterator[T]
- func (iter *DequeIterator[T]) Equal(other iterator.ConstIterator[T]) bool
- func (iter *DequeIterator[T]) IsValid() bool
- func (iter *DequeIterator[T]) IteratorAt(position int) iterator.RandomAccessIterator[T]
- func (iter *DequeIterator[T]) Next() iterator.ConstIterator[T]
- func (iter *DequeIterator[T]) Position() int
- func (iter *DequeIterator[T]) Prev() iterator.ConstBidIterator[T]
- func (iter *DequeIterator[T]) SetValue(val T)
- func (iter *DequeIterator[T]) Value() T
- type Pool
- type Segment
- type T
Constants ¶
const (
SegmentCapacity = 128
)
Constants definition
Variables ¶
var (
ErrOutOfRange = errors.New("out off range")
)
Define internal errors
Functions ¶
This section is empty.
Types ¶
type Deque ¶
type Deque[T any] struct { // contains filtered or unexported fields }
Deque is double-ended queue supports efficient data insertion from the head and tail, random access and iterator access.
func (*Deque[T]) Back ¶
func (d *Deque[T]) Back() T
Back returns the value at the last position of the deque
func (*Deque[T]) Begin ¶
func (d *Deque[T]) Begin() *DequeIterator[T]
Begin returns an iterator of the deque with the first position
func (*Deque[T]) End ¶
func (d *Deque[T]) End() *DequeIterator[T]
End returns an iterator of the deque with the position d.Size()
func (*Deque[T]) EraseRange ¶
EraseRange erases elements in range [firstPos, lastPos)
func (*Deque[T]) First ¶
func (d *Deque[T]) First() *DequeIterator[T]
First returns an iterator of the deque with the first position
func (*Deque[T]) Front ¶
func (d *Deque[T]) Front() T
Front returns the value at the first position of the deque
func (*Deque[T]) IterAt ¶
func (d *Deque[T]) IterAt(pos int) *DequeIterator[T]
IterAt returns an iterator of the deque with the position pos
func (*Deque[T]) Last ¶
func (d *Deque[T]) Last() *DequeIterator[T]
Last returns an iterator of the deque with the last position
func (*Deque[T]) PopBack ¶
func (d *Deque[T]) PopBack() T
PopBack returns the value at the lase position of the deque and removes it
func (*Deque[T]) PopFront ¶
func (d *Deque[T]) PopFront() T
PopFront returns the value at the first position of the deque and removes it
func (*Deque[T]) PushBack ¶
func (d *Deque[T]) PushBack(value T)
PushBack pushed a value to the back of deque
func (*Deque[T]) PushFront ¶
func (d *Deque[T]) PushFront(value T)
PushFront pushed a value to the front of the deque
type DequeIterator ¶
type DequeIterator[T any] struct { // contains filtered or unexported fields }
DequeIterator is an implementation of Deque iterator
func (*DequeIterator[T]) Clone ¶
func (iter *DequeIterator[T]) Clone() iterator.ConstIterator[T]
Clone clones the iterator to a new iterator
func (*DequeIterator[T]) Equal ¶
func (iter *DequeIterator[T]) Equal(other iterator.ConstIterator[T]) bool
Equal returns true if the iterator is equal to the passed iterator, otherwise returns false
func (*DequeIterator[T]) IsValid ¶
func (iter *DequeIterator[T]) IsValid() bool
IsValid returns true if the iterator is valid, otherwise returns false
func (*DequeIterator[T]) IteratorAt ¶
func (iter *DequeIterator[T]) IteratorAt(position int) iterator.RandomAccessIterator[T]
IteratorAt creates a new iterator with the passed position
func (*DequeIterator[T]) Next ¶
func (iter *DequeIterator[T]) Next() iterator.ConstIterator[T]
Next moves the position of the iterator to the next position and returns itself
func (*DequeIterator[T]) Position ¶
func (iter *DequeIterator[T]) Position() int
Position returns the position of iterator
func (*DequeIterator[T]) Prev ¶
func (iter *DequeIterator[T]) Prev() iterator.ConstBidIterator[T]
Prev moves the position of the iterator to the previous position and returns itself
func (*DequeIterator[T]) SetValue ¶
func (iter *DequeIterator[T]) SetValue(val T)
SetValue sets the value of the deque at the position of the iterator point to
func (*DequeIterator[T]) Value ¶
func (iter *DequeIterator[T]) Value() T
Value returns the value of the deque at the position of the iterator point to
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool is a memory pool for holding Segments