コード例 #1
0
 /// <summary>
 /// Returns a cursor that begins at the start bound.
 /// </summary>
 /// <param name="start"></param>
 /// <returns></returns>
 internal static BTree <TK, KeyValuePair <TK, TV> > .Cursor GetStartCursor <TK, TV>(
     BTree <TK, KeyValuePair <TK, TV> > underlying,
     Bound <TK> start)
 {
     if (start == null)
     {
         return(underlying.Begin());
     }
     return(start.IsInclusive
         ? underlying.GreaterThanOrEqual(start.Value, underlying.RootCursor)
         : underlying.GreaterThan(start.Value, underlying.RootCursor));
 }
コード例 #2
0
        /// <summary>
        /// Returns the last key-value pair in the dictionary.  If the dictionary
        /// is empty, this method throws an InvalidOperationException.
        /// </summary>
        internal static KeyValuePair <TK, TV> LastKeyValuePair <TK, TV>(
            BTree <TK, KeyValuePair <TK, TV> > underlying,
            BoundRange <TK> range)
        {
            var upper  = range.Upper;
            var cursor = upper != null
                ? upper.IsInclusive
                    ? underlying.GreaterThanOrEqual(upper.Value, underlying.RootCursor)
                    : underlying.GreaterThan(upper.Value, underlying.RootCursor)
                : underlying.End().MovePrevious();

            if (cursor.IsEnd)
            {
                throw new InvalidOperationException();
            }

            return(cursor.Value);
        }
コード例 #3
0
 public bool TryGreaterThan(
     TK value,
     out TK result)
 {
     return(TryWithCursor(_underlying.GreaterThan(value, _underlying.RootCursor), out result));
 }