Пример #1
0
        /// <exclude/>
        /// <summary>
        /// Compares the equality of two compact array objects.
        /// </summary>
        ///
        /// <param name="obj">the compact array object to be compared with this.</param>
        /// <returns>true if the current compact array object is the same as the
        /// compact array object obj; false otherwise.</returns>
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if ((Object)this == obj)      // quick check
            {
                return(true);
            }
            if ((Object)GetType() != (Object)obj.GetType())       // same class?
            {
                return(false);
            }
            CompactCharArray other = (CompactCharArray)obj;

            for (int i = 0; i < UNICODECOUNT; i++)
            {
                // could be sped up later
                if (ElementAt((char)i) != other.ElementAt((char)i))
                {
                    return(false);
                }
            }
            return(true);    // we made it through the guantlet.
        }
Пример #2
0
 /// <exclude/>
 /// <summary>
 /// Overrides Cloneable
 /// </summary>
 ///
 public Object Clone()
 {
     try {
         CompactCharArray other = (CompactCharArray)base.MemberwiseClone();
         other.values  = (char[])values.Clone();
         other.indices = (char[])indices.Clone();
         if (hashes != null)
         {
             other.hashes = (int[])hashes.Clone();
         }
         return(other);
     } catch (Exception e) {
         throw new InvalidOperationException();
     }
 }