ForgeDocs
Documentation for the forge framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Forge.Collections.Bag< T > Class Template Reference

An unordered collection of items. More...

Inheritance diagram for Forge.Collections.Bag< T >:

Public Member Functions

 Bag ()
 Construct a new bag. More...
 
 Bag (int capacity)
 Construct a new bag with the given initial capacity. More...
 
 Bag (IEnumerable< T > collection)
 Construct a new bag containing all of the elements inside of the given collection. More...
 
 Bag (IList< T > list)
 Construct a new bag containing all of the elements inside of the given list. More...
 
void CopyFrom (Bag< T > bag)
 Copies from the given bag into this one. More...
 
Bag< T > Copy ()
 Creates a duplicate of this bag that has a different backing array. More...
 
int IndexOf (T item)
 Returns the index of the given item in the bag, or -1 if it is not found. More...
 
void Remove (int index)
 Removes the item at given index from the bag in O(1) time. This operation does not maintain the order of elements inside of the bag! More...
 
void Clear ()
 Clears all stored items from this instance. More...
 
bool Remove (T item)
 Remove the item from the bag. This is O(n) and has to scan the bag to find the item. More...
 
void Add (T value)
 
bool Contains (T item)
 Returns true if the Bag contains an instance of the given item. More...
 

Properties

this[int index] [get, set]
 
int Length [get, set]
 

Detailed Description

An unordered collection of items.

Constructor & Destructor Documentation

Forge.Collections.Bag< T >.Bag ( )

Construct a new bag.

Forge.Collections.Bag< T >.Bag ( int  capacity)

Construct a new bag with the given initial capacity.

Parameters
capacityHow many items the bag can store without reallocating internal data structures.
Forge.Collections.Bag< T >.Bag ( IEnumerable< T >  collection)

Construct a new bag containing all of the elements inside of the given collection.

Forge.Collections.Bag< T >.Bag ( IList< T >  list)

Construct a new bag containing all of the elements inside of the given list.

Member Function Documentation

void Forge.Collections.Bag< T >.Clear ( )

Clears all stored items from this instance.

bool Forge.Collections.Bag< T >.Contains ( item)

Returns true if the Bag contains an instance of the given item.

Parameters
itemThe item to search for.
Returns
True if it is in the bag, false otherwise.
Bag<T> Forge.Collections.Bag< T >.Copy ( )

Creates a duplicate of this bag that has a different backing array.

void Forge.Collections.Bag< T >.CopyFrom ( Bag< T >  bag)

Copies from the given bag into this one.

Parameters
bagThe bag to copy from
int Forge.Collections.Bag< T >.IndexOf ( item)

Returns the index of the given item in the bag, or -1 if it is not found.

void Forge.Collections.Bag< T >.Remove ( int  index)

Removes the item at given index from the bag in O(1) time. This operation does not maintain the order of elements inside of the bag!

bool Forge.Collections.Bag< T >.Remove ( item)

Remove the item from the bag. This is O(n) and has to scan the bag to find the item.

Returns
True if the item was found and removed, false otherwise.

The documentation for this class was generated from the following file: