65 return (currentCacheSize >= wipeTo);
115 protected virtual void OnGetWalks(
long totalWalks,
long totalGetOps) {
125 public virtual int NodeCount {
126 get {
return currentCacheSize; }
139 protected abstract bool SetObject(
object key,
object value);
141 protected abstract bool TryGetObject(
object key, out
object value);
143 protected abstract object RemoveObject(
object key);
150 public bool Set(
object key,
object value) {
155 bool newValue = SetObject(key, value);
157 OnObjectAdded(key, value);
162 public bool TryGet(
object key, out
object value) {
163 return TryGetObject(key, out value);
179 object obj = RemoveObject(key);
182 OnObjectRemoved(key, obj);
215 for (
int i = 0; i < PrimeList.Length; ++i) {
216 if (PrimeList[i] >= value) {
221 return PrimeList[PrimeList.Length - 1];
227 private static readonly
int[] PrimeList =
new int[] {
228 3001, 4799, 13999, 15377, 21803, 24247, 35083, 40531, 43669,
229 44263, 47387, 50377, 57059, 57773, 59399, 59999, 75913, 96821,
230 140551, 149011, 175633, 176389, 183299, 205507, 209771, 223099,
231 240259, 258551, 263909, 270761, 274679, 286129, 290531, 296269,
232 298021, 300961, 306407, 327493, 338851, 351037, 365489, 366811,
233 376769, 385069, 410623, 430709, 433729, 434509, 441913, 458531,
234 464351, 470531, 475207, 479629, 501703, 510709, 516017, 522211,
235 528527, 536311, 539723, 557567, 593587, 596209, 597451, 608897,
236 611069, 642547, 670511, 677827, 679051, 688477, 696743, 717683,
237 745931, 757109, 760813, 763957, 766261, 781559, 785597, 788353,
238 804493, 813559, 836917, 854257, 859973, 883217, 884789, 891493,
239 902281, 910199, 915199, 930847, 939749, 940483, 958609, 963847,
240 974887, 983849, 984299, 996211, 999217, 1007519, 1013329,
241 1014287, 1032959, 1035829, 1043593, 1046459, 1076171, 1078109,
242 1081027, 1090303, 1095613, 1098847, 1114037, 1124429, 1125017,
243 1130191, 1159393, 1170311, 1180631, 1198609, 1200809, 1212943,
244 1213087, 1226581, 1232851, 1287109, 1289867, 1297123, 1304987,
245 1318661, 1331107, 1343161, 1345471, 1377793, 1385117, 1394681,
246 1410803, 1411987, 1445261, 1460497, 1463981, 1464391, 1481173,
247 1488943, 1491547, 1492807, 1528993, 1539961, 1545001, 1548247,
248 1549843, 1551001, 1553023, 1571417, 1579099, 1600259, 1606153,
249 1606541, 1639751, 1649587, 1657661, 1662653, 1667051, 1675273,
250 1678837, 1715537, 1718489, 1726343, 1746281, 1749107, 1775489,
251 1781881, 1800157, 1806859, 1809149, 1826753, 1834607, 1846561,
252 1849241, 1851991, 1855033, 1879931, 1891133, 1893737, 1899137,
253 1909513, 1916599, 1917749, 1918549, 1919347, 1925557, 1946489,
254 1961551, 1965389, 2011073, 2033077, 2039761, 2054047, 2060171,
255 2082503, 2084107, 2095099, 2096011, 2112193, 2125601, 2144977,
256 2150831, 2157401, 2170141, 2221829, 2233019, 2269027, 2270771,
257 2292449, 2299397, 2303867, 2309891, 2312407, 2344301, 2348573,
258 2377007, 2385113, 2386661, 2390051, 2395763, 2422999, 2448367,
259 2500529, 2508203, 2509841, 2513677, 2516197, 2518151, 2518177,
260 2542091, 2547469, 2549951, 2556991, 2563601, 2575543, 2597629,
261 2599577, 2612249, 2620003, 2626363, 2626781, 2636773, 2661557,
262 2674297, 2691571, 2718269, 2725691, 2729381, 2772199, 2774953,
263 2791363, 2792939, 2804293, 2843021, 2844911, 2851313, 2863519,
264 2880797, 2891821, 2897731, 2904887, 2910251, 2928943, 2958341,
272 GC.SuppressFinalize(
this);
275 protected virtual void Dispose(
bool disposing) {
virtual bool WipeMoreNodes()
Checks if the clean-up method should clean up more elements from the cache.
virtual int Clean()
Cleans away some old elements in the cache.
int currentCacheSize
The current cache size.
virtual void OnObjectRemoved(object key, Object value)
Notifies that the given object and key has been removed from the cache.
virtual void OnObjectAdded(object key, object value)
Notifies that the given object and key has been added to the cache.
virtual void OnAllCleared()
Notifies that the cache has been entirely cleared of all elements.
bool TryGet(object key, out object value)
Tries to get an object for the given key from the underlying cache system.
virtual void CheckClean()
This is called whenever at object is put into the cache.
virtual void Clear()
Clear the cache of all the entries.
virtual void OnWipingNode(object value)
Notifies that the given object has been wiped from the cache by the clean up procedure.
bool Set(object key, object value)
Puts an object into the cache with the given key.
readonly int wipeTo
The number of nodes that should be left available when the cache becomes too full and a clean up oper...
Represents a cache of Objects. /summary>
virtual void OnGetWalks(long totalWalks, long totalGetOps)
Notifies that some statistical information about the hash map has updated.
Provides a contract to access a caching system.
object Remove(Object key)
Removes a node for the given key from the cache.
static int ClosestPrime(int value)
virtual void Dispose(bool disposing)