OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Properties | List of all members
OpenSim.Framework.MapAndArray< TKey, TValue > Class Template Reference

Stores two synchronized collections: a mutable dictionary and an immutable array. Slower inserts/removes than a normal dictionary, but provides safe iteration while maintaining fast hash lookups More...

Public Member Functions

 MapAndArray ()
 Constructor More...
 
 MapAndArray (int capacity)
 Constructor More...
 
bool AddOrReplace (TKey key, TValue value)
 Adds a key/value pair to the collection, or updates an existing key with a new value More...
 
int Add (TKey key, TValue value)
 Adds a key/value pair to the collection. This will throw an exception if the key is already present in the collection More...
 
bool Remove (TKey key)
 Removes a key/value pair from the collection More...
 
bool ContainsKey (TKey key)
 Determines whether the collections contains a specified key More...
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key More...
 
void Clear ()
 Clears all key/value pairs from the collection More...
 
TValue[] GetArray ()
 Gets a reference to the immutable array of values stored in this collection. This array is thread safe for iteration More...
 

Properties

int Count [get]
 Number of values currently stored in the collection More...
 
object SyncRoot [get]
 NOTE: This collection is thread safe. You do not need to acquire a lock to add, remove, or enumerate entries. This synchronization object should only be locked for larger transactions More...
 

Detailed Description

Stores two synchronized collections: a mutable dictionary and an immutable array. Slower inserts/removes than a normal dictionary, but provides safe iteration while maintaining fast hash lookups

Template Parameters
TKeyKey type to use for hash lookups
TValueValue type to store

Definition at line 40 of file MapAndArray.cs.

Constructor & Destructor Documentation

OpenSim.Framework.MapAndArray< TKey, TValue >.MapAndArray ( )
inline

Constructor

Definition at line 57 of file MapAndArray.cs.

OpenSim.Framework.MapAndArray< TKey, TValue >.MapAndArray ( int  capacity)
inline

Constructor

Parameters
capacityInitial capacity of the dictionary

Definition at line 67 of file MapAndArray.cs.

Member Function Documentation

int OpenSim.Framework.MapAndArray< TKey, TValue >.Add ( TKey  key,
TValue  value 
)
inline

Adds a key/value pair to the collection. This will throw an exception if the key is already present in the collection

Parameters
keyKey to add or update
valueValue to add
Returns
Index of the inserted item

Definition at line 101 of file MapAndArray.cs.

bool OpenSim.Framework.MapAndArray< TKey, TValue >.AddOrReplace ( TKey  key,
TValue  value 
)
inline

Adds a key/value pair to the collection, or updates an existing key with a new value

Parameters
keyKey to add or update
valueValue to add
Returns
True if a new key was added, false if an existing key was updated

Definition at line 81 of file MapAndArray.cs.

void OpenSim.Framework.MapAndArray< TKey, TValue >.Clear ( )
inline

Clears all key/value pairs from the collection

Definition at line 156 of file MapAndArray.cs.

bool OpenSim.Framework.MapAndArray< TKey, TValue >.ContainsKey ( TKey  key)
inline

Determines whether the collections contains a specified key

Parameters
keyKey to search for
Returns
True if the key was found, otherwise false

Definition at line 132 of file MapAndArray.cs.

TValue [] OpenSim.Framework.MapAndArray< TKey, TValue >.GetArray ( )
inline

Gets a reference to the immutable array of values stored in this collection. This array is thread safe for iteration

Returns
A thread safe reference ton an array of all of the stored values

Definition at line 171 of file MapAndArray.cs.

bool OpenSim.Framework.MapAndArray< TKey, TValue >.Remove ( TKey  key)
inline

Removes a key/value pair from the collection

Parameters
keyKey to remove
Returns
True if the key was found and removed, otherwise false

Definition at line 116 of file MapAndArray.cs.

bool OpenSim.Framework.MapAndArray< TKey, TValue >.TryGetValue ( TKey  key,
out TValue  value 
)
inline

Gets the value associated with the specified key

Parameters
keyKey of the value to get
valueWill contain the value associated with the given key if the key is found. If the key is not found it will contain the default value for the type of the value parameter
Returns
True if the key was found and a value was retrieved, otherwise false

Definition at line 147 of file MapAndArray.cs.

Property Documentation

int OpenSim.Framework.MapAndArray< TKey, TValue >.Count
get

Number of values currently stored in the collection

Definition at line 47 of file MapAndArray.cs.

object OpenSim.Framework.MapAndArray< TKey, TValue >.SyncRoot
get

NOTE: This collection is thread safe. You do not need to acquire a lock to add, remove, or enumerate entries. This synchronization object should only be locked for larger transactions

Definition at line 52 of file MapAndArray.cs.


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