BagItem Class |
The Bag class represents a bag (or multiset) of generic items. It supports insertion and iterating over the items in arbitrary order.
This implementation uses a singly-linked list with a nested, non-static class Node and hence is the same as the LinkedBag class in algs4.jar. The Add, IsEmpty, and Count operations take constant time. Iteration takes time proportional to the number of items.
Namespace: Algs4Net
The BagItem type exposes the following members.
Name | Description | |
---|---|---|
![]() | Count | Returns the number of items in this bag. |
![]() | IsEmpty |
Returns true if this bag is empty. |
Name | Description | |
---|---|---|
![]() | Add | Adds the item to this bag. |
![]() | GetEnumerator |
Returns an enumerator that iterates over the items in this bag in arbitrary order. |
![]() ![]() | MainTest |
Demo test for the Bag data type. |
![]() | ToString |
Returns a string representation in the format "it1 it2 it3 ... itn" (LIFO order)
(Overrides ObjectToString.) |
For additional documentation, see Section 9.9 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class FFT implementation by the respective authors.