ResizingArrayBagItem Class |
The ResizingArrayBag class represents a bag (or multiset) of generic items. It supports insertion and iterating over the items in arbitrary order.
This implementation uses a resizing array. See for a version that uses a singly-linked list. The Add operation takes constant amortized time; the IsEmpty, and Count operations take constant time. Iteration takes time proportional to the number of items.
Namespace: Algs4Net
The ResizingArrayBagItem type exposes the following members.
Name | Description | |
---|---|---|
![]() | ResizingArrayBagItem | Initializes an empty bag. |
Name | Description | |
---|---|---|
![]() | Add |
Adds the item to this bag. |
![]() | GetEnumerator |
Returns an iterator that iterates over the items in the bag in arbitrary order. |
![]() ![]() | MainTest |
Demo test the ResizingArrayBag data type. |
For additional documentation, see Section 1.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class ResizingArrayBag implementation by the respective authors.