Esempio n. 1
0
        public virtual void Insert(int index, T item)
        {
            LongDecimal newRowId;

            if (index == 0)
            {
                if (Tree.Count == 0)
                {
                    newRowId = new LongDecimal(1);
                }
                else
                {
                    newRowId = ((LongDecimal)Tree[0].Key).GetPredecessor();
                }
            }
            else if (index == Tree.Count)
            {
                newRowId = ((LongDecimal)Tree[Tree.Count - 1].Key).GetSuccessor();
            }
            else
            {
                newRowId =
                    ((LongDecimal)Tree[index - 1].Key).MidPoint(
                        (LongDecimal)Tree[index].Key);
            }
            Tree.Add(newRowId, item);
        }
Esempio n. 2
0
        public LongDecimal MidPoint(LongDecimal that)
        {
            var result = new LongDecimal(0)
            {
                _doubleValue = (_doubleValue + that._doubleValue) / 2
            };

            if (result.Equals(this) || result.Equals(that))
            {
                return(null);
            }
            return(result);
        }