AutoMapper
This expression visitor will replace an input parameter by another one
see http://stackoverflow.com/questions/4601844/expression-tree-copy-or-convert
Search key structure for
Type of the key.
Type of the value.
A Concurrent implementation.
Type of the keys.
Type of the values.
This class is threadsafe and highly concurrent. This means that multiple threads can do lookup and insert operations
on this dictionary simultaneously.
It is not guaranteed that collisions will not occur. The dictionary is partitioned in segments. A segment contains
a set of items based on a hash of those items. The more segments there are and the beter the hash, the fewer collisions will occur.
This means that a nearly empty ConcurrentDictionary is not as concurrent as one containing many items.
Base class for concurrent hashtable implementations
Type of the items stored in the hashtable.
Type of the key to search with.
Constructor (protected)
Use Initialize method after construction.
Initialize the newly created ConcurrentHashtable. Invoke in final (sealed) constructor
or Create method.
Create a segment range
Number of segments in range.
Number of slots allocated initialy in each segment.
The created instance.
While adjusting the segmentation, _NewRange will hold a reference to the new range of segments.
when the adjustment is complete this reference will be copied to _CurrentRange.
Will hold the most current reange of segments. When busy adjusting the segmentation, this
field will hold a reference to the old range.
While adjusting the segmentation this field will hold a boundary.
Clients accessing items with a key hash value below this boundary (unsigned compared)
will access _NewRange. The others will access _CurrentRange
Get a hashcode for given storeable item.
Reference to the item to get a hash value for.
The hash value as an .
The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
A storeable item and a matching search key should return the same hash code.
So the statement ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true
should always be true;
Get a hashcode for given search key.
Reference to the key to get a hash value for.
The hash value as an .
The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
A storeable item and a matching search key should return the same hash code.
So the statement ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true
should always be true;
Compares a storeable item to a search key. Should return true if they match.
Reference to the storeable item to compare.
Reference to the search key to compare.
True if the storeable item and search key match; false otherwise.
Compares two storeable items for equality.
Reference to the first storeable item to compare.
Reference to the second storeable item to compare.
True if the two soreable items should be regarded as equal.
Indicates if a specific item reference contains a valid item.
The storeable item reference to check.
True if the reference doesn't refer to a valid item; false otherwise.
The statement IsEmpty(default(TStoredI))
should always be true.
Returns the type of the key value or object.
The stored item to get the type of the key for.
The actual type of the key or null if it can not be determined.
Used for diagnostics purposes.
Gets a segment out of either _NewRange or _CurrentRange based on the hash value.
Gets a LOCKED segment out of either _NewRange or _CurrentRange based on the hash value.
Unlock needs to be called on this segment before it can be used by other clients.
Gets a LOCKED segment out of either _NewRange or _CurrentRange based on the hash value.
Unlock needs to be called on this segment before it can be used by other clients.
Finds an item in the table collection that maches the given searchKey
The key to the item.
Out reference to a field that will receive the found item.
A boolean that will be true if an item has been found and false otherwise.
Looks for an existing item in the table contents using an alternative copy. If it can be found it will be returned.
If not then the alternative copy will be added to the table contents and the alternative copy will be returned.
A copy to search an already existing instance with
Out reference to receive the found item or the alternative copy
A boolean that will be true if an existing copy was found and false otherwise.
Replaces and existing item
true is the existing item was successfully replaced.
Inserts an item in the table contents possibly replacing an existing item.
The item to insert in the table
Out reference to a field that will receive any possibly replaced item.
A boolean that will be true if an existing copy was found and replaced and false otherwise.
Removes an item from the table contents.
The key to find the item with.
Out reference to a field that will receive the found and removed item.
A boolean that will be rue if an item was found and removed and false otherwise.
Enumerates all segments in _CurrentRange and locking them before yielding them and resleasing the lock afterwards
The order in which the segments are returned is undefined.
Lock SyncRoot before using this enumerable.
Removes all items from the collection.
Aquires a lock on SyncRoot before it does it's thing.
When this method returns and multiple threads have access to this table it
is not guaranteed that the table is actually empty.
Determines if a segmentation adjustment is needed.
True
Bool as int (for interlocked functions) that is true if a Segmentation assesment is pending.
The total allocated number of item slots. Filled with nonempty items or not.
When a segment resizes it uses this method to inform the hashtable of the change in allocated space.
Schedule a call to the AssessSegmentation() method.
Checks if segmentation needs to be adjusted and if so performs the adjustment.
This method is called when a re-segmentation is expected to be needed. It checks if it actually is needed and, if so, performs the re-segementation.
Adjusts the segmentation to the new segment count
The new number of segments to use. This must be a power of 2.
The number of item slots to reserve in each segment.
Returns an object that serves as a lock for range operations
Clients use this primarily for enumerating over the Tables contents.
Locking doesn't guarantee that the contents don't change, but prevents operations that would
disrupt the enumeration process.
Operations that use this lock:
Count, Clear, DisposeGarbage and AssessSegmentation.
Keeping this lock will prevent the table from re-segmenting.
Gets an IEnumerable to iterate over all items in all segments.
A lock should be aquired and held on SyncRoot while this IEnumerable is being used.
The order in which the items are returned is undetermined.
Returns a count of all items in teh collection. This may not be
aqurate when multiple threads are accessing this table.
Aquires a lock on SyncRoot before it does it's thing.
Gives the minimum number of segments a hashtable can contain. This should be 1 or more and always a power of 2.
Gives the minimum number of allocated item slots per segment. This should be 1 or more, always a power of 2
and less than 1/2 of MeanSegmentAllocatedSpace.
Gives the prefered number of allocated item slots per segment. This should be 4 or more and always a power of 2.
Constructs a instance using the default to compare keys.
Constructs a instance using the specified to compare keys.
The tp compare keys with.
is null.
Get a hashcode for given storeable item.
Reference to the item to get a hash value for.
The hash value as an .
The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
A storeable item and a matching search key should return the same hash code.
So the statement ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true
should always be true;
Get a hashcode for given search key.
Reference to the key to get a hash value for.
The hash value as an .
The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
A storeable item and a matching search key should return the same hash code.
So the statement ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true
should always be true;
Compares a storeable item to a search key. Should return true if they match.
Reference to the storeable item to compare.
Reference to the search key to compare.
True if the storeable item and search key match; false otherwise.
Compares two storeable items for equality.
Reference to the first storeable item to compare.
Reference to the second storeable item to compare.
True if the two soreable items should be regarded as equal.
Indicates if a specific item reference contains a valid item.
The storeable item reference to check.
True if the reference doesn't refer to a valid item; false otherwise.
The statement IsEmpty(default(TStoredI))
should always be true.
Adds an element with the provided key and value to the dictionary.
The object to use as the key of the element to add.
The object to use as the value of the element to add.
An element with the same key already exists in the dictionary.
Determines whether the dictionary
contains an element with the specified key.
The key to locate in the dictionary.
true if the dictionary contains
an element with the key; otherwise, false.
Removes the element with the specified key from the dictionary.
The key of the element to remove.
true if the element is successfully removed; otherwise, false. This method
also returns false if key was not found in the original dictionary.
Gets the value associated with the specified key.
The key whose value to get.
When this method returns, the value associated with the specified key, if
the key is found; otherwise, the default value for the type of the value
parameter. This parameter is passed uninitialized.
true if the dictionary contains an element with the specified key; otherwise, false.
Adds an association to the dictionary.
A that represents the association to add.
An association with an equal key already exists in the dicitonary.
Removes all items from the dictionary.
WHen working with multiple threads, that each can add items to this dictionary, it is not guaranteed that the dictionary will be empty when this method returns.
Determines whether the specified association exists in the dictionary.
The key-value association to search fo in the dicionary.
True if item is found in the dictionary; otherwise, false.
This method compares both key and value. It uses the default equality comparer to compare values.
Copies all associations of the dictionary to an
, starting at a particular index.
The one-dimensional that is the destination of the associations
copied from . The must
have zero-based indexing.
The zero-based index in at which copying begins.
is null.
is less than 0.
is equal to or greater than the length of .
The number of associations to be copied
is greater than the available space from to the end of the destination
.
Removes the specified association from the , comparing both key and value.
A representing the association to remove.
true if the association was successfully removed from the ;
otherwise, false. This method also returns false if the association is not found in
the original .
Returns an enumerator that iterates through all associations in the at the moment of invocation.
A that can be used to iterate through the associations.
Returns an enumerator that iterates through all associations in the at the moment of invocation.
A that can be used to iterate through the associations.
Gives the of TKey that is used to compare keys.
Gets an containing the keys of
the dictionary.
An containing the keys of the dictionary.
This property takes a snapshot of the current keys collection of the dictionary at the moment of invocation.
Gets an containing the values in
the dictionary.
An containing the values in the dictionary.
This property takes a snapshot of the current keys collection of the dictionary at the moment of invocation.
Gets or sets the value associated with the specified key.
The key of the value to get or set.
The value associated with the specified key. If the specified key is not found, a get operation throws a KeyNotFoundException, and a set operation creates a new element with the specified key.
When working with multiple threads, that can each potentialy remove the searched for item, a can always be expected.
Gets the number of elements contained in the .
Gets a value indicating whether the is read-only, which is always false.
A 'single writer - multi reader' threaded segment in a hashtable.
Though each segment can be accessed by 1 writer thread simultaneously, the hashtable becomes concurrent
for writing by containing many segments so that collisions are rare. The table will be fully concurrent
for read operations as far as they are not colliding with write operations.
Each segment is itself a small hashtable that can grow and shrink individualy. This prevents blocking of
the entire hashtable when growing or shrinking is needed. Because each segment is relatively small (depending on
the quality of the hash) resizing of the individual segments should not take much time.
Initialize the segment.
When segment gets introduced into hashtable then its allocated space should be added to the
total allocated space.
Single threaded access or locking is needed
When segment gets removed from hashtable then its allocated space should be subtracted to the
total allocated space.
Single threaded access or locking is needed
Array with 'slots'. Each slot can be filled or empty.
Inserts an item into a *not empty* spot given by position i. It moves items forward until an empty spot is found.
Find item in segment.
Reference to the search key to use.
Out reference to store the found item in.
Object that tells this segment how to treat items and keys.
True if an item could be found, otherwise false.
Find an existing item or, if it can't be found, insert a new item.
Reference to the item that will be inserted if an existing item can't be found. It will also be used to search with.
Out reference to store the found item or, if it can not be found, the new inserted item.
Object that tells this segment how to treat items and keys.
True if an existing item could be found, otherwise false.
Inserts an item in the segment, possibly replacing an equal existing item.
A reference to the item to insert.
An out reference where any replaced item will be written to, if no item was replaced the new item will be written to this reference.
Object that tells this segment how to treat items and keys.
True if an existing item could be found and is replaced, otherwise false.
Removes an item from the segment.
A reference to the key to search with.
An out reference where the removed item will be stored or default() if no item to remove can be found.
Object that tells this segment how to treat items and keys.
True if an item could be found and is removed, false otherwise.
Iterate over items in the segment.
Position beyond which the next filled slot will be found and the item in that slot returned. (Starting with -1)
Out reference where the next item will be stored or default if the end of the segment is reached.
Object that tells this segment how to treat items and keys.
The index position the next item has been found or -1 otherwise.
Total numer of filled slots in _List.
Remove any excess allocated space
Boolean value indicating if this segment has not been trashed yet.
Tiny spin lock that allows multiple readers simultanously and 1 writer exclusively
Release a reader lock
Release a writer lock
Aquire a reader lock. Wait until lock is aquired.
Aquire a reader lock.
True if to wait until lock aquired, False to return immediately.
Boolean indicating if lock was successfuly aquired.
Aquire a writer lock. Wait until lock is aquired.
Aquire a writer lock.
True if to wait until lock aquired, False to return immediately.
Boolean indicating if lock was successfuly aquired.
Attempts to replicate the Desktop CLR.