Esempio n. 1
0
        /// <summary>
        ///		Find dictionary items around the specified key value
        /// </summary>
        /// <param name="cutKey">
        ///		The covered key value around which to find items in the dictionary
        /// </param>
        /// <param name="lowItem">
        ///		On output - the immediate predecessor of <paramref name="cutKey"/>; the value's key will always be
        ///		strictly less than <paramref name="cutKey"/>; if node exists, <code>default(V)</code> is returned
        ///		(for reference types it's <see langword="null"/>);
        /// </param>
        /// <param name="highItem">
        ///		On output - the immediate successor of <paramref name="cutKey"/>; the value's key will always be
        ///		strictly greater than <paramref name="cutKey"/>; if node exists, <code>default(V)</code> is returned
        ///		(for reference types it's <see langword="null"/>);
        /// </param>
        /// <returns>
        ///		<see langword="true"/> if item with exact same key as <paramref name="cutKey"/> exists in the dictionary;
        ///		<see langword="false"/> otherwise
        /// </returns>
        public bool Cut(K cutKey, out V lowItem, out V highItem)
        {
            C5.KeyValuePair <K, V> lowEntry;
            C5.KeyValuePair <K, V> highEntry;
            bool lowExists;
            bool highExists;

            bool retval = _dictionary.Cut(cutKey, out lowEntry, out lowExists, out highEntry, out highExists);

            if (lowExists)
            {
                lowItem = lowEntry.Value;
            }
            else
            {
                lowItem = default(V);
            }

            if (highExists)
            {
                highItem = highEntry.Value;
            }
            else
            {
                highItem = default(V);
            }

            return(retval);
        }