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

Inheritance Hierarchy
SystemObject
  Algs4NetResizingArrayBagItem

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

Type Parameters

Item

The ResizingArrayBagItem type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCount
Returns the number of items in this bag.
Public propertyIsEmpty
Is this bag empty?
Top
Methods
  NameDescription
Public methodAdd
Adds the item to this bag.
Public methodGetEnumerator
Returns an iterator that iterates over the items in the bag in arbitrary order.
Public methodStatic memberMainTest
Demo test the ResizingArrayBag data type.
Top
Remarks

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.

See Also