System.Collections.Hashtable.Clone C# (CSharp) Method

Clone() public method

public Clone ( ) : Object
return Object
        public virtual Object Clone()
        {
            bucket[] lbuckets = _buckets;
            Hashtable ht = new Hashtable(_count, _keycomparer);
            ht._version = _version;
            ht._loadFactor = _loadFactor;
            ht._count = 0;

            int bucket = lbuckets.Length;
            while (bucket > 0)
            {
                bucket--;
                Object keyv = lbuckets[bucket].key;
                if ((keyv != null) && (keyv != lbuckets))
                {
                    ht[keyv] = lbuckets[bucket].val;
                }
            }

            return ht;
        }

Usage Example

		private Color[] SelectHighestFrecuency(Hashtable histogram)
		{
			Color[]   salida = new Color[NumColors];
			Hashtable HCopy  = (Hashtable)histogram.Clone();

			Color pixel;
			int i=0;
			while (i<NumColors)
			{
				if (HCopy.Count == 0) {break;}

				pixel = HighestFrecuency(HCopy);

				salida[i] = pixel;
				HCopy.Remove(pixel);

				i++;
			}

			while (i<NumColors)
			{
				salida[i] = Color.Empty;
				i++;
			}

			return salida;
		}
All Usage Examples Of System.Collections.Hashtable::Clone