Documentation
¶
Index ¶
- type InterruptedErr
- type Iterator
- type LinkedBlockingDeque
- func (q *LinkedBlockingDeque) AddFirst(e interface{}) error
- func (q *LinkedBlockingDeque) AddLast(e interface{}) error
- func (q *LinkedBlockingDeque) DescendingIterator() Iterator
- func (q *LinkedBlockingDeque) HasTakeWaiters() bool
- func (q *LinkedBlockingDeque) InterruptTakeWaiters()
- func (q *LinkedBlockingDeque) Iterator() Iterator
- func (q *LinkedBlockingDeque) OfferFirst(e interface{}) bool
- func (q *LinkedBlockingDeque) OfferLast(e interface{}) bool
- func (q *LinkedBlockingDeque) PeekFirst() interface{}
- func (q *LinkedBlockingDeque) PeekLast() interface{}
- func (q *LinkedBlockingDeque) PollFirst() (e interface{})
- func (q *LinkedBlockingDeque) PollFirstWithContext(ctx context.Context) (interface{}, error)
- func (q *LinkedBlockingDeque) PollLast() interface{}
- func (q *LinkedBlockingDeque) PollLastWithContext(ctx context.Context) (interface{}, error)
- func (q *LinkedBlockingDeque) PutFirst(ctx context.Context, e interface{})
- func (q *LinkedBlockingDeque) PutLast(ctx context.Context, e interface{})
- func (q *LinkedBlockingDeque) RemoveFirstOccurrence(item interface{}) bool
- func (q *LinkedBlockingDeque) RemoveLastOccurrence(item interface{}) bool
- func (q *LinkedBlockingDeque) Size() int
- func (q *LinkedBlockingDeque) TakeFirst(ctx context.Context) (interface{}, error)
- func (q *LinkedBlockingDeque) TakeLast(ctx context.Context) (interface{}, error)
- func (q *LinkedBlockingDeque) ToSlice() []interface{}
- type LinkedBlockingDequeIterator
- type Node
- type SyncIdentityMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InterruptedErr ¶
type InterruptedErr struct { }
InterruptedErr when deque block method bean interrupted will return this err
func NewInterruptedErr ¶
func NewInterruptedErr() *InterruptedErr
NewInterruptedErr return new error instance
func (*InterruptedErr) Error ¶
func (err *InterruptedErr) Error() string
type Iterator ¶
type Iterator interface { HasNext() bool Next() interface{} Remove() }
Iterator interface for collection see LinkedBlockDequeIterator
type LinkedBlockingDeque ¶
type LinkedBlockingDeque struct {
// contains filtered or unexported fields
}
LinkedBlockingDeque is a concurrent safe blocking deque
func NewDeque ¶
func NewDeque(capacity int) *LinkedBlockingDeque
NewDeque return a LinkedBlockingDeque with init capacity
func (*LinkedBlockingDeque) AddFirst ¶
func (q *LinkedBlockingDeque) AddFirst(e interface{}) error
AddFirst inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, return error if no space is currently available.
func (*LinkedBlockingDeque) AddLast ¶
func (q *LinkedBlockingDeque) AddLast(e interface{}) error
AddLast inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, return error if no space is currently available.
func (*LinkedBlockingDeque) DescendingIterator ¶
func (q *LinkedBlockingDeque) DescendingIterator() Iterator
DescendingIterator return a desc iterator of this deque
func (*LinkedBlockingDeque) HasTakeWaiters ¶
func (q *LinkedBlockingDeque) HasTakeWaiters() bool
HasTakeWaiters returns true if there are goroutine waiting to take instances from this deque. See disclaimer on accuracy in TimeoutCond.HasWaiters()
func (*LinkedBlockingDeque) InterruptTakeWaiters ¶
func (q *LinkedBlockingDeque) InterruptTakeWaiters()
InterruptTakeWaiters interrupts the goroutine currently waiting to take an object from the pool.
func (*LinkedBlockingDeque) Iterator ¶
func (q *LinkedBlockingDeque) Iterator() Iterator
Iterator return a asc iterator of this deque
func (*LinkedBlockingDeque) OfferFirst ¶
func (q *LinkedBlockingDeque) OfferFirst(e interface{}) bool
OfferFirst inserts the specified element at the front of this deque unless it would violate capacity restrictions. return if the element was added to this deque
func (*LinkedBlockingDeque) OfferLast ¶
func (q *LinkedBlockingDeque) OfferLast(e interface{}) bool
OfferLast inserts the specified element at the end of this deque unless it would violate capacity restrictions. return if the element was added to this deque
func (*LinkedBlockingDeque) PeekFirst ¶
func (q *LinkedBlockingDeque) PeekFirst() interface{}
PeekFirst retrieves, but does not remove, the first element of this deque, or returns nil if this deque is empty.
func (*LinkedBlockingDeque) PeekLast ¶
func (q *LinkedBlockingDeque) PeekLast() interface{}
PeekLast retrieves, but does not remove, the last element of this deque, or returns nil if this deque is empty.
func (*LinkedBlockingDeque) PollFirst ¶
func (q *LinkedBlockingDeque) PollFirst() (e interface{})
PollFirst retrieves and removes the first element of this deque, or returns nil if this deque is empty.
func (*LinkedBlockingDeque) PollFirstWithContext ¶
func (q *LinkedBlockingDeque) PollFirstWithContext(ctx context.Context) (interface{}, error)
PollFirstWithContext retrieves and removes the first element of this deque, waiting until the context is done if necessary for an element to become available. return NewInterruptedErr when waiting bean interrupted
func (*LinkedBlockingDeque) PollLast ¶
func (q *LinkedBlockingDeque) PollLast() interface{}
PollLast retrieves and removes the last element of this deque, or returns nil if this deque is empty.
func (*LinkedBlockingDeque) PollLastWithContext ¶
func (q *LinkedBlockingDeque) PollLastWithContext(ctx context.Context) (interface{}, error)
PollLastWithContext retrieves and removes the last element of this deque, waiting until the context is done if necessary for an element to become available. return NewInterruptedErr when waiting bean interrupted
func (*LinkedBlockingDeque) PutFirst ¶
func (q *LinkedBlockingDeque) PutFirst(ctx context.Context, e interface{})
PutFirst link the provided element as the first in the queue, waiting until there is space to do so if the queue is full.
func (*LinkedBlockingDeque) PutLast ¶
func (q *LinkedBlockingDeque) PutLast(ctx context.Context, e interface{})
PutLast Link the provided element as the last in the queue, waiting until there is space to do so if the queue is full.
func (*LinkedBlockingDeque) RemoveFirstOccurrence ¶
func (q *LinkedBlockingDeque) RemoveFirstOccurrence(item interface{}) bool
RemoveFirstOccurrence removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element item such that
o == item
(if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
func (*LinkedBlockingDeque) RemoveLastOccurrence ¶
func (q *LinkedBlockingDeque) RemoveLastOccurrence(item interface{}) bool
RemoveLastOccurrence removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element item such that
o == item
(if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
func (*LinkedBlockingDeque) Size ¶
func (q *LinkedBlockingDeque) Size() int
Size return this LinkedBlockingDeque current elements len, is concurrent safe
func (*LinkedBlockingDeque) TakeFirst ¶
func (q *LinkedBlockingDeque) TakeFirst(ctx context.Context) (interface{}, error)
TakeFirst unlink the first element in the queue, waiting until there is an element to unlink if the queue is empty. return NewInterruptedErr if wait condition is interrupted
func (*LinkedBlockingDeque) TakeLast ¶
func (q *LinkedBlockingDeque) TakeLast(ctx context.Context) (interface{}, error)
TakeLast unlink the last element in the queue, waiting until there is an element to unlink if the queue is empty. return NewInterruptedErr if wait condition is interrupted
func (*LinkedBlockingDeque) ToSlice ¶
func (q *LinkedBlockingDeque) ToSlice() []interface{}
ToSlice returns an slice containing all of the elements in this deque, in proper sequence (from first to last element).
type LinkedBlockingDequeIterator ¶
type LinkedBlockingDequeIterator struct {
// contains filtered or unexported fields
}
LinkedBlockingDequeIterator is iterator implements for LinkedBlockingDeque
func (*LinkedBlockingDequeIterator) HasNext ¶
func (iterator *LinkedBlockingDequeIterator) HasNext() bool
HasNext return is exist next element
func (*LinkedBlockingDequeIterator) Next ¶
func (iterator *LinkedBlockingDequeIterator) Next() interface{}
Next return next element, if not exist will return nil
func (*LinkedBlockingDequeIterator) Remove ¶
func (iterator *LinkedBlockingDequeIterator) Remove()
Remove current element from dequeue
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is LinkedBlockingDeque's element
type SyncIdentityMap ¶
SyncIdentityMap is a concurrent safe map use key's pointer as map key
func (*SyncIdentityMap) Put ¶
func (m *SyncIdentityMap) Put(key interface{}, value interface{})
Put key and value to map
func (*SyncIdentityMap) Remove ¶
func (m *SyncIdentityMap) Remove(key interface{})
Remove value by key
func (*SyncIdentityMap) Size ¶
func (m *SyncIdentityMap) Size() int
Size return map len, and is concurrent safe
func (*SyncIdentityMap) Values ¶
func (m *SyncIdentityMap) Values() []interface{}
Values copy all map's value to slice