Example #1
0
        public bool Equals(RuneString other)
        {
            if (other.IsNull())
            {
                return(false);
            }
            else if (base.Equals(other))
            {
                return(true);
            }
            else if (this.hashcode == other.hashcode && this.Length == other.Length)
            {
                for (int i = 0; i < runes.Length; i++)
                {
                    if (runes[i] != other.runes[i])
                    {
                        return(false);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public static RuneString Replicate(RuneString value, int count)
        {
            var values = new RuneString[count];

            for (int i = 0; i < count; i++)
            {
                values[i] = value;
            }

            return(Combine(values));
        }
Example #3
0
 public static bool IsEqualTo(RuneString left, RuneString right)
 {
     if (left.IsNull())
     {
         return(right.IsNull());
     }
     else
     {
         return(left.Equals(right));
     }
 }
Example #4
0
        public static RuneString Combine(RuneString left, Rune right)
        {
            if (left == null)
            {
                return(new RuneString(right));
            }

            var combined = new Rune[left.Length + 1];

            Array.Copy(left.runes, 0, combined, 0, left.Length);

            combined[left.Length] = right;

            return(new RuneString(combined, false));
        }
Example #5
0
        public static RuneString Combine(Rune left, RuneString right)
        {
            if (right == null)
            {
                return(new RuneString(left));
            }


            var combined = new Rune[right.Length + 1];

            combined[0] = left;

            Array.Copy(right.runes, 1, combined, 0, right.Length);

            return(new RuneString(combined, false));
        }
Example #6
0
        private static IEnumerable <RuneString> GetEnumerable(RuneString separator, IEnumerable <RuneString> values)
        {
            bool initialized = false;

            foreach (var value in values)
            {
                if (initialized)
                {
                    yield return(separator);
                }
                else
                {
                    initialized = true;
                }

                yield return(value);
            }
        }
Example #7
0
 public static int Compare(RuneString left, RuneString right)
 {
     if (left.IsNull())
     {
         if (right.IsNull())
         {
             return(0);
         }
         else
         {
             return(-1);
         }
     }
     else
     {
         return(left.CompareTo(right));
     }
 }
Example #8
0
        private static IEnumerable <RuneString> GetEnumerable(RuneString separator, IEnumerable <object> values)
        {
            bool initialized = false;

            foreach (var value in values)
            {
                if (initialized)
                {
                    yield return(separator);
                }
                else
                {
                    initialized = true;
                }

                var result = value == null ? Empty : new RuneString(value.ToString());

                yield return(result);
            }
        }
Example #9
0
        public static RuneString Combine(RuneString left, RuneString right)
        {
            if (left == null)
            {
                return(right);
            }

            if (right == null)
            {
                return(null);
            }

            var combined = new Rune[left.Length + right.Length];

            Array.Copy(left.runes, 0, combined, 0, left.Length);

            Array.Copy(right.runes, left.Length, combined, 0, right.Length);

            return(new RuneString(combined, false));
        }
Example #10
0
        public int CompareTo(RuneString other)
        {
            // Treat null like empty
            if (other == null)
            {
                return(1);
            }

            int length = Math.Min(this.Length, other.Length);

            for (int i = 0; i < length; i++)
            {
                var thisRune  = this.runes[i];
                var otherRune = other.runes[i];

                var result = thisRune.CompareTo(otherRune);

                if (result != 0)
                {
                    return(result);
                }
            }

            // All runes that line up match up, so we have to sort by length
            if (this.Length < other.Length)
            {
                return(-1);
            }
            else if (this.Length > other.Length)
            {
                return(+1);
            }
            else
            {
                return(0);
            }
        }
 public static RuneSet List(RuneString runes) => FromList(runes);
Example #12
0
 public static RuneString Join(RuneString separator, IEnumerable <object> values) => Combine(GetEnumerable(separator, values));
Example #13
0
 public static RuneString Join(RuneString separator, params RuneString[] values) => Join(separator, values);
Example #14
0
 public static bool IsNullOrEmpty(RuneString value) => value == null || value.IsEmpty;