Пример #1
0
        /// <summary>
        /// {@inheritDoc}
        ///
        /// @implSpec
        /// This implementation iterates over <tt>entrySet()</tt> searching for an
        /// entry with the specified key.  If such an entry is found, its value is
        /// obtained with its <tt>getValue</tt> operation, the entry is removed
        /// from the collection (and the backing map) with the iterator's
        /// <tt>remove</tt> operation, and the saved value is returned.  If the
        /// iteration terminates without finding such an entry, <tt>null</tt> is
        /// returned.  Note that this implementation requires linear time in the
        /// size of the map; many implementations will override this method.
        ///
        /// <para>Note that this implementation throws an
        /// <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt>
        /// iterator does not support the <tt>remove</tt> method and this map
        /// contains a mapping for the specified key.
        ///
        /// </para>
        /// </summary>
        /// <exception cref="UnsupportedOperationException"> {@inheritDoc} </exception>
        /// <exception cref="ClassCastException">            {@inheritDoc} </exception>
        /// <exception cref="NullPointerException">          {@inheritDoc} </exception>
        public virtual V Remove(Object key)
        {
            Iterator <Map_Entry <K, V> > i            = EntrySet().Iterator();
            Map_Entry <K, V>             correctEntry = Map_Fields.Null;

            if (key == Map_Fields.Null)
            {
                while (correctEntry == Map_Fields.Null && i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (e.Key == Map_Fields.Null)
                    {
                        correctEntry = e;
                    }
                }
            }
            else
            {
                while (correctEntry == Map_Fields.Null && i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (key.Equals(e.Key))
                    {
                        correctEntry = e;
                    }
                }
            }

            V Map_Fields.OldValue = Map_Fields.Null;

            if (correctEntry != Map_Fields.Null)
            {
                Map_Fields.OldValue = correctEntry.Value;
                i.remove();
            }
            return(Map_Fields.OldValue);
        }
Пример #2
0
 public virtual void Remove()
 {
     i.remove();
 }