Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetBagItem

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Bag<Item> : IEnumerable<Item>, IEnumerable

Type Parameters

Item

The BagItem type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCount
Returns the number of items in this bag.
Public propertyIsEmpty
Returns true if this bag is empty.
Top
Methods
  NameDescription
Public methodAdd
Adds the item to this bag.
Public methodGetEnumerator
Returns an enumerator that iterates over the items in this bag in arbitrary order.
Public methodStatic memberMainTest
Demo test for the Bag data type.
Public methodToString
Returns a string representation in the format "it1 it2 it3 ... itn" (LIFO order)
(Overrides ObjectToString.)
Top
Remarks

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.

See Also