SolidKit.Dictionary generic
From Solid Graphics Wiki
| ||||||||||
The Dictionary generic is a .NET generic for making sorted key-to-value maps. The generic is defined as:
public class Dictionary_< TKey, TValue >
The TKey is type of the dictionary keys, the TValue is type of the dictionary values.
Contrary to similar dictionary types used in other libraries such as System.Collections.Generic.Dictionary, the SolidKit's dictionary does not automatically sort key-value pairs as they are added to dictionary. Explicit call to the dictionary's Sort method is needed to sort the dictionary items. This is for performance reasons as sorting the dictionary once after all it's items are added to it is usually faster than sorting it during inserting of each item.
Constructors
The Dictionary generic provides only basic constructors.
Fields
The template provides no public fields.
Methods
| Method name | Description |
| Clear | Removes all key-value pairs from the dictionary and sets the dictionary capacity to zero. |
| Add | Adds key-value pair to the end of the dictionary. |
| Insert | Inserts key-value pair to specified dictionary position. |
| InsertOrReplace | Inserts key-value pair at specified position, or if the key already exists there then it replaces it's value with the new value. |
| RemoveAt | Erases key-value pair at specified dictionary position. |
| Count | Count of the dictionary items. When property is set to value of less than current count then the item past the specified count are erased. If set to value which is more than current count then new dictionary items are initialized to default values. |
| Sort | Sorts items in the dictionary in ascending order using items keys to determine the sort order. |
| IndexOf | To use this method the dictionary must be sorted in ascending order. Finds and returns index of dictionary item with the specified key using binary-search algorithm. If there are more key-value pairs using the same key then the method does not necessarily returns first's such key-value pair index. If the key is not present in the dictionary then the method returns -1. |
| IndexOfEqualOrGreater | To use this method the dictionary must be sorted in ascending order. Finds and returns index of dictionary item with key equal or greater than the specified key. If there are more key-value pairs using the same key then the method does not necessarily returns first's such key-value pair index. If the key is not present in the dictionary then the method returns -1. |
| GetItemValue | Returns value of dictionary item with specified index. |
| Capacity | Returns current dictionary's capacity or sets the dictionary capacity to specified value. Setting the capacity first ensures that the internal data buffer for the dictionary items won't be reallocated if number of items added to the dictionary does not exceed the capacity value. |
See Also
SolidKit Library Documentation
