コード例 #1
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 public static int Compare(NodeIndex index1, NodeIndex index2)
 {
     if (index1 < index2)
     {
         return -1;
     }
     if (index1 > index2)
     {
         return 1;
     }
     return 0;
 }
コード例 #2
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 internal static bool CreateBetween(NodeIndex before, NodeIndex after, out NodeIndex index)
 {
     return Create(before.bigValue, before.smallValue, after.bigValue, after.smallValue, out index);
 }
コード例 #3
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 internal static bool CreateBefore(NodeIndex after, out NodeIndex index)
 {
     return Create(-2147483648, -32768, after.bigValue, after.smallValue, out index);
 }
コード例 #4
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 internal static bool CreateAfter(NodeIndex before, out NodeIndex index)
 {
     return Create(before.bigValue, before.smallValue, 0x7fffffff, 0x7fff, out index);
 }
コード例 #5
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 internal static bool CreateFirst(out NodeIndex index)
 {
     return Create(-2147483648, -32768, 0x7fffffff, 0x7fff, out index);
 }
コード例 #6
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 private static bool Create(int previousBigValue, short previousSmallValue, int nextBigValue, short nextSmallValue, out NodeIndex index)
 {
     int num;
     short num2;
     index = new NodeIndex();
     if (previousBigValue == nextBigValue)
     {
         num = previousBigValue;
         if (!CreateSmallValue(previousSmallValue, nextSmallValue, out num2))
         {
             return false;
         }
     }
     else if (CreateBigValue(previousBigValue, nextBigValue, out num))
     {
         num2 = 0;
     }
     else if (num == previousBigValue)
     {
         if (!CreateSmallValue(previousSmallValue, nextSmallValue, out num2))
         {
             return false;
         }
     }
     else
     {
         return false;
     }
     index.bigValue = num;
     index.smallValue = num2;
     return true;
 }
コード例 #7
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
        /// <summary>
        /// Creates an index for a new node.
        /// </summary>
        /// <param name="previousBigValue">The big value of the previous node.</param>
        /// <param name="previousSmallValue">The small value of the previous node.</param>
        /// <param name="nextBigValue">The big value of the next node.</param>
        /// <param name="nextSmallValue">The small value of the next node.</param>
        /// <param name="index">Returns the new index.</param>
        /// <returns>Returns true if the new index was created, or false if there are no more indexes.</returns>
        private static bool Create(int previousBigValue, short previousSmallValue, int nextBigValue, short nextSmallValue, out NodeIndex index)
        {
            Param.Ignore(previousBigValue, previousSmallValue, nextBigValue, nextSmallValue);

            // Validate the conditions we allow.
            Debug.Assert(
                (previousBigValue < nextBigValue) ||
                ((previousBigValue == nextBigValue) && (previousSmallValue < nextSmallValue)) ||
                ((previousBigValue == nextSmallValue) && (previousSmallValue == nextSmallValue)),
                "The values are not allowed.");

            int bigValue;
            short smallValue;

            index = new NodeIndex();

            // Check whether the indexes are the same up to the small value.
            if (previousBigValue == nextBigValue)
            {
                bigValue = previousBigValue;

                if (!CreateSmallValue(previousSmallValue, nextSmallValue, out smallValue))
                {
                    return false;
                }
            }
            else
            {
                if (CreateBigValue(previousBigValue, nextBigValue, out bigValue))
                {
                    smallValue = 0;
                }
                else if (bigValue == previousBigValue)
                {
                    if (!CreateSmallValue(previousSmallValue, nextSmallValue, out smallValue))
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }

            index.bigValue = bigValue;
            index.smallValue = smallValue;

            return true;
        }
コード例 #8
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 /// <summary>
 /// Creates an index for a new node which is the first node in the list.
 /// </summary>
 /// <param name="index">Returns the new index.</param>
 /// <returns>Returns true if the new index was created, or false if there are no more indexes.</returns>
 internal static bool CreateFirst(out NodeIndex index)
 {
     return Create(int.MinValue, short.MinValue, int.MaxValue, short.MaxValue, out index);
 }
コード例 #9
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 /// <summary>
 /// Creates an index for a new node being inserted at the beginning of the list.
 /// </summary>
 /// <param name="after">The index of the next node.</param>
 /// <param name="index">Returns the new index.</param>
 /// <returns>Returns true if the new index was created, or false if there are no more indexes.</returns>
 internal static bool CreateBefore(NodeIndex after, out NodeIndex index)
 {
     Param.Ignore(after);
     return Create(int.MinValue, short.MinValue, after.bigValue, after.smallValue, out index);
 }
コード例 #10
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
 /// <summary>
 /// Creates an index for a new node being inserted at the beginning of the list.
 /// </summary>
 /// <param name="before">The index of the previous node.</param>
 /// <param name="index">Returns the new index.</param>
 /// <returns>Returns true if the new index was created, or false if there are no more indexes.</returns>
 internal static bool CreateAfter(NodeIndex before, out NodeIndex index)
 {
     Param.Ignore(before);
     return Create(before.bigValue, before.smallValue, int.MaxValue, short.MaxValue, out index);
 }
コード例 #11
0
ファイル: NodeIndex.cs プロジェクト: katerina-marchenkova/my
        /// <summary>
        /// Compares the two indexes and returns a standard comparison result.
        /// </summary>
        /// <param name="index1">The first index.</param>
        /// <param name="index2">The second index.</param>
        /// <returns>Returns a negative value if the first index is less than the second index, a positive
        /// value if the second index is greater than the first index, or zero if the two indexes are equal.</returns>
        public static int Compare(NodeIndex index1, NodeIndex index2)
        {
            Param.Ignore(index1, index2);

            if (index1 < index2)
            {
                return -1;
            }
            else if (index1 > index2)
            {
                return 1;
            }

            return 0;
        }