new ConstrainedStack(maxSizeopt, eqCompareropt)
Creates a new, empty Stack..
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
maxSize |
Number |
<optional> |
Optional. Defaults to Number.MAX_SAFE_INTEGER. Use this parameter to limit the maximum amount of elements this Stack can hold. When the limit is reached and items are being further pushed, the ConstrainedStack will pop items from the BOTTOM. I.e., when pushing a new item to the top of the Stack when it is full, will discard one item at its bottom. This parameter must be a positive integer larger than zero. |
eqComparer |
EqualityComparer.<T> |
<optional> |
Optional. Defaults To
EqualityComparer. |
- Source:
Members
maxSize
- Source:
maxSize
Sets the maximum size of this ConstrainedStack. If currently there are more
items, the stack will pop items from the bottom until the number of items
does not longer exceed the new maximum size. The items will be popped from
the BOTTOM.
- Source:
Methods
_truncate() → {this}
- Source:
Returns:
- Type
- this
push(item) → {this}
Push an item to the top of the Stack. If, after pushing this item,
the Stack is larger than its specified maximum size, it will discard
an item from the BOTTOM.
Parameters:
Name | Type | Description |
---|---|---|
item |
T |
- Source:
Returns:
- Type
- this