public bool Equals(USlice other)
        {
            if (this.Count != other.Count)
            {
                return(false);
            }
            if (this.Data == other.Data)
            {
                return(true);
            }
            if (this.Data == null || other.Data == null)
            {
                return(false);
            }

            //TODO: optimize!
            return(0 == UnmanagedHelpers.CompareUnsafe(this.Data, this.Count, other.Data, other.Count));
        }
 public int CompareTo(USlice other)
 {
     return(UnmanagedHelpers.CompareUnsafe(this.Data, this.Count, other.Data, other.Count));
 }
 /// <summary>Checks if two slices are equal.</summary>
 /// <param name="x">Slice compared with <paramref name="y"/></param>
 /// <param name="y">Slice compared with <paramref name="x"/></param>
 /// <returns>true if <paramref name="x"/> and <paramref name="y"/> have the same size and contain the same sequence of bytes; otherwise, false.</returns>
 public bool Equals(USlice x, USlice y)
 {
     return(x.Count == y.Count && 0 == UnmanagedHelpers.CompareUnsafe(x.Data, x.Count, y.Data, y.Count));
 }
 int IComparer <KeyValuePair <USlice, USlice> > .Compare(KeyValuePair <USlice, USlice> x, KeyValuePair <USlice, USlice> y)
 {
     return(UnmanagedHelpers.CompareUnsafe(x.Key.Data, x.Key.Count, y.Key.Data, y.Key.Count));
 }
 /// <summary>Lexicographically compare two slices and returns an indication of their relative sort order</summary>
 /// <param name="x">Slice compared with <paramref name="y"/></param>
 /// <param name="y">Slice compared with <paramref name="x"/></param>
 /// <returns>Returns a NEGATIVE value if <paramref name="x"/> is LESS THAN <paramref name="y"/>, ZERO if <paramref name="x"/> is EQUAL TO <paramref name="y"/>, and a POSITIVE value if <paramref name="x"/> is GREATER THAN <paramref name="y"/>.</returns>
 /// <remarks>If both <paramref name="x"/> and <paramref name="y"/> are nil or empty, the comparison will return ZERO. If only <paramref name="y"/> is nil or empty, it will return a NEGATIVE value. If only <paramref name="x"/> is nil or empty, it will return a POSITIVE value.</remarks>
 public int Compare(USlice x, USlice y)
 {
     return(UnmanagedHelpers.CompareUnsafe(x.Data, x.Count, y.Data, y.Count));
 }