29 using System.Collections.Generic;
31 namespace OpenSim.Framework
40 public sealed
class MapAndArray<TKey, TValue>
42 private Dictionary<TKey, TValue> m_dict;
43 private TValue[] m_array;
44 private object m_syncRoot =
new object();
47 public int Count {
get {
return m_array.Length; } }
52 public object SyncRoot {
get {
return m_syncRoot; } }
59 m_dict =
new Dictionary<TKey, TValue>();
60 m_array =
new TValue[0];
69 m_dict =
new Dictionary<TKey, TValue>(capacity);
70 m_array =
new TValue[0];
85 bool containedKey = m_dict.ContainsKey(
key);
105 m_dict.Add(
key, value);
107 return m_array.Length;
120 bool removed = m_dict.Remove(
key);
135 return m_dict.ContainsKey(
key);
150 return m_dict.TryGetValue(
key, out value);
160 m_dict =
new Dictionary<TKey, TValue>();
161 m_array =
new TValue[0];
176 private void CreateArray()
180 TValue[] array =
new TValue[m_dict.Count];
183 foreach (TValue value
in m_dict.Values)
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 i...
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
TValue[] GetArray()
Gets a reference to the immutable array of values stored in this collection. This array is thread saf...
MapAndArray(int capacity)
Constructor
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key
bool AddOrReplace(TKey key, TValue value)
Adds a key/value pair to the collection, or updates an existing key with a new value ...
void Clear()
Clears all key/value pairs from the collection
bool Remove(TKey key)
Removes a key/value pair from the collection
bool ContainsKey(TKey key)
Determines whether the collections contains a specified key