Hashtable.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. //
  2. // System.Collections.Hashtable
  3. //
  4. // Author:
  5. // Sergey Chaban ([email protected])
  6. //
  7. using System;
  8. using System.Collections;
  9. // TODO: 1. Interfaces to implement: ISerializable and IDeserializationCallback;
  10. // 2. Meaningfull error messages for all exceptions.
  11. // Probably we should use ResourceSet to translate
  12. // error codes to messages.
  13. namespace System.Collections {
  14. public class Hashtable : IDictionary, ICollection,
  15. IEnumerable, ICloneable
  16. {
  17. internal struct Slot {
  18. internal Object key;
  19. internal Object value;
  20. // Hashcode. Chains are also marked through this.
  21. internal int hashMix;
  22. }
  23. //
  24. // Private data
  25. //
  26. private readonly static int CHAIN_MARKER = ~Int32.MaxValue;
  27. private readonly static int ALLOC_GRAIN = 0x2F;
  28. // Used as indicator for the removed parts of a chain.
  29. private readonly static Object REMOVED_MARKER = new Object ();
  30. private int inUse;
  31. private int modificationCount;
  32. private float loadFactor;
  33. private Slot [] table;
  34. private int threshold;
  35. private IHashCodeProvider hcpRef;
  36. private IComparer comparerRef;
  37. public static int [] primeTbl = {};
  38. // Class constructor
  39. static Hashtable () {
  40. // NOTE: Precalculate primes table.
  41. // This precalculated table of primes is intended
  42. // to speed-up allocations/resize for relatively
  43. // small tables.
  44. // I'm not sure whether it's a good idea or not.
  45. // Also I am in doubt as for the quality of this
  46. // particular implementation, probably the increment
  47. // shouldn't be linear? Consider this as a hack
  48. // or as a placeholder for future improvements.
  49. int size = 0x2000/ALLOC_GRAIN;
  50. primeTbl = new int [size];
  51. for (int x = 53, i = 0;i<size;x+= ALLOC_GRAIN, i++) {
  52. primeTbl [i] = CalcPrime (x);
  53. }
  54. }
  55. //
  56. // Constructors
  57. //
  58. public Hashtable () : this (0, 1.0f) {}
  59. public Hashtable (int capacity, float loadFactor, IHashCodeProvider hcp, IComparer comparer) {
  60. if (capacity<0)
  61. throw new ArgumentOutOfRangeException ("negative capacity");
  62. if (loadFactor<0.1 || loadFactor>1)
  63. throw new ArgumentOutOfRangeException ("load factor");
  64. if (capacity == 0) ++capacity;
  65. this.loadFactor = 0.75f*loadFactor;
  66. int size = (int) (capacity/this.loadFactor);
  67. size = ToPrime (size);
  68. this.SetTable (new Slot [size]);
  69. this.hcp = hcp;
  70. this.comparer = comparer;
  71. this.inUse = 0;
  72. this.modificationCount = 0;
  73. }
  74. public Hashtable (int capacity, float loadFactor) :
  75. this (capacity, loadFactor, null, null)
  76. {
  77. }
  78. public Hashtable (int capacity) : this (capacity, 1.0f)
  79. {
  80. }
  81. public Hashtable (int capacity,
  82. IHashCodeProvider hcp,
  83. IComparer comparer)
  84. : this (capacity, 1.0f, hcp, comparer)
  85. {
  86. }
  87. public Hashtable (IDictionary d, float loadFactor,
  88. IHashCodeProvider hcp, IComparer comparer)
  89. : this (d!=null ? d.Count : 0,
  90. loadFactor, hcp, comparer)
  91. {
  92. if (d == null)
  93. throw new ArgumentNullException ("dictionary");
  94. IDictionaryEnumerator it = d.GetEnumerator ();
  95. while (it.MoveNext ()) {
  96. Add (it.Key, it.Value);
  97. }
  98. }
  99. public Hashtable (IDictionary d, float loadFactor)
  100. : this (d, loadFactor, null, null)
  101. {
  102. }
  103. public Hashtable (IDictionary d) : this (d, 1.0f)
  104. {
  105. }
  106. public Hashtable (IDictionary d, IHashCodeProvider hcp, IComparer comparer)
  107. : this (d, 1.0f, hcp, comparer)
  108. {
  109. }
  110. public Hashtable (IHashCodeProvider hcp, IComparer comparer)
  111. : this (1, 1.0f, hcp, comparer)
  112. {
  113. }
  114. //
  115. // Properties
  116. //
  117. protected IComparer comparer {
  118. set {
  119. comparerRef = value;
  120. }
  121. get {
  122. return comparerRef;
  123. }
  124. }
  125. protected IHashCodeProvider hcp {
  126. set {
  127. hcpRef = value;
  128. }
  129. get {
  130. return hcpRef;
  131. }
  132. }
  133. // ICollection
  134. public virtual int Count {
  135. get {
  136. return inUse;
  137. }
  138. }
  139. public virtual bool IsSynchronized {
  140. get {
  141. return false;
  142. }
  143. }
  144. public virtual Object SyncRoot {
  145. get {
  146. return this;
  147. }
  148. }
  149. // IDictionary
  150. public virtual bool IsFixedSize {
  151. get {
  152. return false;
  153. }
  154. }
  155. public virtual bool IsReadOnly {
  156. get {
  157. return false;
  158. }
  159. }
  160. public virtual ICollection Keys {
  161. get {
  162. return new HashKeys (this);
  163. }
  164. }
  165. public virtual ICollection Values {
  166. get {
  167. return new HashValues (this);
  168. }
  169. }
  170. public virtual Object this [Object key] {
  171. get {
  172. return GetImpl (key);
  173. }
  174. set {
  175. PutImpl (key, value, true);
  176. }
  177. }
  178. //
  179. // Interface methods
  180. //
  181. // IEnumerable
  182. IEnumerator IEnumerable.GetEnumerator ()
  183. {
  184. return new Enumerator (this, EnumeratorMode.KEY_MODE);
  185. }
  186. // ICollection
  187. public virtual void CopyTo (Array array, int arrayIndex)
  188. {
  189. IDictionaryEnumerator it = GetEnumerator ();
  190. int i = arrayIndex;
  191. while (it.MoveNext ()) {
  192. array.SetValue (it.Entry, i++);
  193. }
  194. }
  195. // IDictionary
  196. public virtual void Add (Object key, Object value)
  197. {
  198. PutImpl (key, value, false);
  199. }
  200. public virtual void Clear ()
  201. {
  202. for (int i = 0;i<table.Length;i++) {
  203. table [i].key = null;
  204. table [i].value = null;
  205. table [i].hashMix = 0;
  206. }
  207. inUse = 0;
  208. modificationCount++;
  209. }
  210. public virtual bool Contains (Object key)
  211. {
  212. return (Find (key) >= 0);
  213. }
  214. public virtual IDictionaryEnumerator GetEnumerator ()
  215. {
  216. return new Enumerator (this, EnumeratorMode.KEY_MODE);
  217. }
  218. public virtual void Remove (Object key)
  219. {
  220. int i = Find (key);
  221. Slot [] table = this.table;
  222. if (i >= 0) {
  223. int h = table [i].hashMix;
  224. h &= CHAIN_MARKER;
  225. table [i].hashMix = h;
  226. table [i].key = (h != 0)
  227. ? REMOVED_MARKER
  228. : null;
  229. table [i].value = null;
  230. --inUse;
  231. ++modificationCount;
  232. }
  233. }
  234. public virtual bool ContainsKey (object key)
  235. {
  236. return Contains (key);
  237. }
  238. public virtual bool ContainsValue (object value)
  239. {
  240. int size = this.table.Length;
  241. Slot [] table = this.table;
  242. for (int i = 0; i < size; i++) {
  243. Slot entry = table [i];
  244. if (entry.key != null && entry.key!= REMOVED_MARKER
  245. && value.Equals (entry.value)) {
  246. return true;
  247. }
  248. }
  249. return false;
  250. }
  251. // ICloneable
  252. public virtual object Clone ()
  253. {
  254. Hashtable ht = new Hashtable (Count, hcp, comparer);
  255. ht.modificationCount = this.modificationCount;
  256. ht.inUse = this.inUse;
  257. ht.AdjustThreshold ();
  258. // FIXME: maybe it's faster to simply
  259. // copy the back-end array?
  260. IDictionaryEnumerator it = GetEnumerator ();
  261. while (it.MoveNext ()) {
  262. ht [it.Key] = it.Value;
  263. }
  264. return ht;
  265. }
  266. // TODO: public virtual void GetObjectData (SerializationInfo info, StreamingContext context) {}
  267. // TODO: public virtual void OnDeserialization (object sender);
  268. public override string ToString ()
  269. {
  270. // FIXME: What's it supposed to do?
  271. // Maybe print out some internals here? Anyway.
  272. return "mono::System.Collections.Hashtable";
  273. }
  274. /// <summary>
  275. /// Returns a synchronized (thread-safe)
  276. /// wrapper for the Hashtable.
  277. /// </summary>
  278. public static Hashtable Synchronized (Hashtable table)
  279. {
  280. return new SynchedHashtable (table);
  281. }
  282. //
  283. // Protected instance methods
  284. //
  285. /// <summary>Returns the hash code for the specified key.</summary>
  286. protected virtual int GetHash (Object key)
  287. {
  288. IHashCodeProvider hcp = this.hcp;
  289. return (hcp!= null)
  290. ? hcp.GetHashCode (key)
  291. : key.GetHashCode ();
  292. }
  293. /// <summary>
  294. /// Compares a specific Object with a specific key
  295. /// in the Hashtable.
  296. /// </summary>
  297. protected virtual bool KeyEquals (Object item, Object key)
  298. {
  299. IComparer c = this.comparer;
  300. if (c!= null)
  301. return (c.Compare (item, key) == 0);
  302. else
  303. return item.Equals (key);
  304. }
  305. //
  306. // Private instance methods
  307. //
  308. private void AdjustThreshold ()
  309. {
  310. int size = table.Length;
  311. threshold = (int) (size*loadFactor);
  312. if (this.threshold >= size)
  313. threshold = size-1;
  314. }
  315. private void SetTable (Slot [] table)
  316. {
  317. if (table == null)
  318. throw new ArgumentNullException ("table");
  319. this.table = table;
  320. AdjustThreshold ();
  321. }
  322. private Object GetImpl (Object key)
  323. {
  324. int i = Find (key);
  325. if (i >= 0)
  326. return table [i].value;
  327. else
  328. return null;
  329. }
  330. private int Find (Object key)
  331. {
  332. if (key == null)
  333. throw new ArgumentNullException ("null key");
  334. uint size = (uint) this.table.Length;
  335. int h = this.GetHash (key) & Int32.MaxValue;
  336. uint spot = (uint)h;
  337. uint step = (uint) ((h >> 5)+1) % (size-1)+1;
  338. Slot[] table = this.table;
  339. for (int i = 0; i < size;i++) {
  340. int indx = (int) (spot % size);
  341. Slot entry = table [indx];
  342. Object k = entry.key;
  343. if (k == null)
  344. return -1;
  345. if ((entry.hashMix & Int32.MaxValue) == h
  346. && this.KeyEquals (key, k)) {
  347. return indx;
  348. }
  349. if ((entry.hashMix & CHAIN_MARKER) == 0)
  350. return -1;
  351. spot+= step;
  352. }
  353. return -1;
  354. }
  355. private void Rehash ()
  356. {
  357. int oldSize = this.table.Length;
  358. // From the SDK docs:
  359. // Hashtable is automatically increased
  360. // to the smallest prime number that is larger
  361. // than twice the current number of Hashtable buckets
  362. uint newSize = (uint)ToPrime ((oldSize<<1)|1);
  363. Slot [] newTable = new Slot [newSize];
  364. Slot [] table = this.table;
  365. for (int i = 0;i<oldSize;i++) {
  366. Slot s = table [i];
  367. if (s.key!= null) {
  368. int h = s.hashMix & Int32.MaxValue;
  369. uint spot = (uint)h;
  370. uint step = ((uint) (h>>5)+1)% (newSize-1)+1;
  371. for (uint j = spot%newSize;;spot+= step, j = spot%newSize) {
  372. // No check for REMOVED_MARKER here,
  373. // because the table is just allocated.
  374. if (newTable [j].key == null) {
  375. newTable [j].key = s.key;
  376. newTable [j].value = s.value;
  377. newTable [j].hashMix |= h;
  378. break;
  379. } else {
  380. newTable [j].hashMix |= CHAIN_MARKER;
  381. }
  382. }
  383. }
  384. }
  385. ++this.modificationCount;
  386. this.SetTable (newTable);
  387. }
  388. private void PutImpl (Object key, Object value, bool overwrite)
  389. {
  390. if (key == null)
  391. throw new ArgumentNullException ("null key");
  392. uint size = (uint)this.table.Length;
  393. if (this.inUse >= this.threshold) {
  394. this.Rehash ();
  395. size = (uint)this.table.Length;
  396. }
  397. int h = this.GetHash (key) & Int32.MaxValue;
  398. uint spot = (uint)h;
  399. uint step = (uint) ((spot>>5)+1)% (size-1)+1;
  400. Slot [] table = this.table;
  401. Slot entry;
  402. int freeIndx = -1;
  403. for (int i = 0; i < size; i++) {
  404. int indx = (int) (spot % size);
  405. entry = table [indx];
  406. if (freeIndx == -1
  407. && entry.key == REMOVED_MARKER
  408. && (entry.hashMix & CHAIN_MARKER)!= 0)
  409. freeIndx = indx;
  410. if (entry.key == null ||
  411. (entry.key == REMOVED_MARKER
  412. && (entry.hashMix & CHAIN_MARKER)!= 0)) {
  413. if (freeIndx == -1)
  414. freeIndx = indx;
  415. break;
  416. }
  417. if ((entry.hashMix & Int32.MaxValue) == h && KeyEquals (key, entry.key)) {
  418. if (overwrite) {
  419. table [indx].value = value;
  420. ++this.modificationCount;
  421. } else {
  422. // Handle Add ():
  423. // An entry with the same key already exists in the Hashtable.
  424. throw new ArgumentException ("Key duplication");
  425. }
  426. return;
  427. }
  428. if (freeIndx == -1) {
  429. table [indx].hashMix |= CHAIN_MARKER;
  430. }
  431. spot+= step;
  432. }
  433. if (freeIndx!= -1) {
  434. table [freeIndx].key = key;
  435. table [freeIndx].value = value;
  436. table [freeIndx].hashMix |= h;
  437. ++this.inUse;
  438. ++this.modificationCount;
  439. }
  440. }
  441. private void CopyToArray (Array arr, int i,
  442. EnumeratorMode mode)
  443. {
  444. IEnumerator it = new Enumerator (this, mode);
  445. while (it.MoveNext ()) {
  446. arr.SetValue (it.Current, i++);
  447. }
  448. }
  449. //
  450. // Private static methods
  451. //
  452. private static bool TestPrime (int x)
  453. {
  454. if ((x & 1) != 0) {
  455. for (int n = 3; n< (int)Math.Sqrt (x); n += 2) {
  456. if ((x % n) == 0)
  457. return false;
  458. }
  459. return true;
  460. }
  461. // There is only one even prime - 2.
  462. return (x == 2);
  463. }
  464. private static int CalcPrime (int x)
  465. {
  466. for (int i = (x & (~1))-1; i< Int32.MaxValue; i += 2) {
  467. if (TestPrime (i)) return i;
  468. }
  469. return x;
  470. }
  471. private static int ToPrime (int x)
  472. {
  473. for (int i = x/ALLOC_GRAIN; i < primeTbl.Length; i++) {
  474. if (x <= primeTbl [i])
  475. return primeTbl [i];
  476. }
  477. return CalcPrime (x);
  478. }
  479. //
  480. // Inner classes
  481. //
  482. public enum EnumeratorMode : int {KEY_MODE = 0, VALUE_MODE};
  483. protected sealed class Enumerator : IDictionaryEnumerator, IEnumerator {
  484. private Hashtable host;
  485. private int stamp;
  486. private int pos;
  487. private int size;
  488. private EnumeratorMode mode;
  489. private Object currentKey;
  490. private Object currentValue;
  491. private readonly static string xstr = "Hashtable.Enumerator: snapshot out of sync.";
  492. public Enumerator (Hashtable host, EnumeratorMode mode) {
  493. this.host = host;
  494. stamp = host.modificationCount;
  495. size = host.table.Length;
  496. this.mode = mode;
  497. Reset ();
  498. }
  499. public Enumerator (Hashtable host)
  500. : this (host, EnumeratorMode.KEY_MODE) {}
  501. private void FailFast ()
  502. {
  503. if (host.modificationCount!= stamp) {
  504. throw new InvalidOperationException (xstr);
  505. }
  506. }
  507. public void Reset ()
  508. {
  509. FailFast ();
  510. pos = -1;
  511. currentKey = null;
  512. currentValue = null;
  513. }
  514. public bool MoveNext ()
  515. {
  516. FailFast ();
  517. if (pos < size) {
  518. while (++pos < size) {
  519. Slot entry = host.table [pos];
  520. if (entry.key != null && entry.key != REMOVED_MARKER) {
  521. currentKey = entry.key;
  522. currentValue = entry.value;
  523. return true;
  524. }
  525. }
  526. }
  527. currentKey = null;
  528. currentValue = null;
  529. return false;
  530. }
  531. public DictionaryEntry Entry
  532. {
  533. get {
  534. FailFast ();
  535. return new DictionaryEntry (currentKey, currentValue);
  536. }
  537. }
  538. public Object Key {
  539. get {
  540. FailFast ();
  541. return currentKey;
  542. }
  543. }
  544. public Object Value {
  545. get {
  546. FailFast ();
  547. return currentValue;
  548. }
  549. }
  550. public Object Current {
  551. get {
  552. FailFast ();
  553. return (mode == EnumeratorMode.KEY_MODE)
  554. ? currentKey
  555. : currentValue;
  556. }
  557. }
  558. }
  559. protected class HashKeys : ICollection, IEnumerable {
  560. private Hashtable host;
  561. private int count;
  562. public HashKeys (Hashtable host) {
  563. if (host == null)
  564. throw new ArgumentNullException ();
  565. this.host = host;
  566. this.count = host.Count;
  567. }
  568. // ICollection
  569. public virtual int Count {
  570. get {
  571. return count;
  572. }
  573. }
  574. public virtual bool IsSynchronized {
  575. get {
  576. return host.IsSynchronized;
  577. }
  578. }
  579. public virtual Object SyncRoot {
  580. get {return host.SyncRoot;}
  581. }
  582. public virtual void CopyTo (Array array, int arrayIndex)
  583. {
  584. host.CopyToArray (array, arrayIndex, EnumeratorMode.KEY_MODE);
  585. }
  586. // IEnumerable
  587. public virtual IEnumerator GetEnumerator ()
  588. {
  589. return new Hashtable.Enumerator (host, EnumeratorMode.KEY_MODE);
  590. }
  591. }
  592. protected class HashValues : ICollection, IEnumerable {
  593. private Hashtable host;
  594. private int count;
  595. public HashValues (Hashtable host) {
  596. if (host == null)
  597. throw new ArgumentNullException ();
  598. this.host = host;
  599. this.count = host.Count;
  600. }
  601. // ICollection
  602. public virtual int Count {
  603. get {
  604. return count;
  605. }
  606. }
  607. public virtual bool IsSynchronized {
  608. get {
  609. return host.IsSynchronized;
  610. }
  611. }
  612. public virtual Object SyncRoot {
  613. get {
  614. return host.SyncRoot;
  615. }
  616. }
  617. public virtual void CopyTo (Array array, int arrayIndex)
  618. {
  619. host.CopyToArray (array, arrayIndex, EnumeratorMode.VALUE_MODE);
  620. }
  621. // IEnumerable
  622. public virtual IEnumerator GetEnumerator ()
  623. {
  624. return new Hashtable.Enumerator (host, EnumeratorMode.VALUE_MODE);
  625. }
  626. }
  627. protected class SynchedHashtable : Hashtable, IEnumerable {
  628. private Hashtable host;
  629. public SynchedHashtable (Hashtable host) {
  630. if (host == null)
  631. throw new ArgumentNullException ();
  632. this.host = host;
  633. }
  634. // ICollection
  635. public override int Count {
  636. get {
  637. return host.Count;
  638. }
  639. }
  640. public override bool IsSynchronized {
  641. get {
  642. return true;
  643. }
  644. }
  645. public override Object SyncRoot {
  646. get {
  647. return host.SyncRoot;
  648. }
  649. }
  650. // IDictionary
  651. public override bool IsFixedSize {
  652. get {
  653. return host.IsFixedSize;
  654. }
  655. }
  656. public override bool IsReadOnly {
  657. get {
  658. return host.IsReadOnly;
  659. }
  660. }
  661. public override ICollection Keys {
  662. get {
  663. ICollection keys = null;
  664. lock (host.SyncRoot) {
  665. keys = host.Keys;
  666. }
  667. return keys;
  668. }
  669. }
  670. public override ICollection Values {
  671. get {
  672. ICollection vals = null;
  673. lock (host.SyncRoot) {
  674. vals = host.Values;
  675. }
  676. return vals;
  677. }
  678. }
  679. public override Object this [Object key] {
  680. get {
  681. return host.GetImpl (key);
  682. }
  683. set {
  684. lock (host.SyncRoot) {
  685. host.PutImpl (key, value, true);
  686. }
  687. }
  688. }
  689. // IEnumerable
  690. IEnumerator IEnumerable.GetEnumerator ()
  691. {
  692. return new Enumerator (host, EnumeratorMode.KEY_MODE);
  693. }
  694. // ICollection
  695. public override void CopyTo (Array array, int arrayIndex)
  696. {
  697. host.CopyTo (array, arrayIndex);
  698. }
  699. // IDictionary
  700. public override void Add (Object key, Object value)
  701. {
  702. lock (host.SyncRoot) {
  703. host.PutImpl (key, value, false);
  704. }
  705. }
  706. public override void Clear ()
  707. {
  708. lock (host.SyncRoot) {
  709. host.Clear ();
  710. }
  711. }
  712. public override bool Contains (Object key)
  713. {
  714. return (host.Find (key) >= 0);
  715. }
  716. public override IDictionaryEnumerator GetEnumerator ()
  717. {
  718. return new Enumerator (host, EnumeratorMode.KEY_MODE);
  719. }
  720. public override void Remove (Object key)
  721. {
  722. lock (host.SyncRoot) {
  723. host.Remove (key);
  724. }
  725. }
  726. public override bool ContainsKey (object key)
  727. {
  728. return host.Contains (key);
  729. }
  730. public override bool ContainsValue (object value)
  731. {
  732. return host.ContainsValue (value);
  733. }
  734. // ICloneable
  735. public override object Clone ()
  736. {
  737. return (host.Clone () as Hashtable);
  738. }
  739. } // SynchedHashtable
  740. } // Hashtable
  741. }