DequeOverflowPolicy Enum
Definition
- Namespace
- Bodu.Collections.Generic
- Assembly
- Bodu.Collections.dll
- Package
- Bodu.Collections 1.0.0
- Source
- DequeOverflowPolicy.cs
Specifies how a fixed-capacity Deque<T> responds when an add operation is attempted while the deque is already full.
public enum DequeOverflowPolicy
- Extension Methods
Fields
Reject = 0Adds to a full deque are rejected: AddFirst(T) and AddLast(T) throw InvalidOperationException, while TryAddFirst(T) and TryAddLast(T) return false without modifying state. This is the default and preserves the historical fixed-capacity behavior.
EvictOpposite = 1Adds to a full deque silently discard the element at the opposite end to make room - the tail element for AddFirst(T), the head element for AddLast(T) - so Count stays at Capacity and the
Try*variants return true. This mirrors Python'scollections.deque(maxlen=N)bounded-deque semantics.
Remarks
The policy is consulted only when AllowGrow is false and Count equals Capacity. When AllowGrow is true the backing array grows instead, so the policy has no effect.
EvictOpposite is the double-ended counterpart of the overwrite-on-full mode selected by
AllowOverwrite, and matches the semantics of Python's
collections.deque(maxlen=N).
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |