示例#1
0
 public virtual bool remove(object @object)
 {
     java.util.Iterator <E> it = iterator();
     if (@object != null)
     {
         while (it.hasNext())
         {
             if (@object.Equals(it.next()))
             {
                 it.remove();
                 return(true);
             }
         }
     }
     else
     {
         while (it.hasNext())
         {
             if (it.next() == null)
             {
                 it.remove();
                 return(true);
             }
         }
     }
     return(false);
 }
示例#2
0
        /**
         * Adds an delete change.
         *
         * @param pChange
         *            the change which should result in a deletion
         */
        private void addDeletion(Change pChange)
        {
            if ((Change.TYPE_DELETE != pChange.type() &&
                 Change.TYPE_DELETE_DIR != pChange.type()) ||
                pChange.targetFile() == null)
            {
                return;
            }
            String source = pChange.targetFile();

            if (!changes.isEmpty())
            {
                for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();)
                {
                    Change change = (Change)it.next();
                    if (change.type() == Change.TYPE_ADD &&
                        change.getEntry() != null)
                    {
                        String target = change.getEntry().getName();

                        if (Change.TYPE_DELETE == pChange.type() && source.equals(target))
                        {
                            it.remove();
                        }
                        else if (Change.TYPE_DELETE_DIR == pChange.type() &&
                                 target.matches(source + "/.*"))
                        {
                            it.remove();
                        }
                    }
                }
            }
            changes.add(pChange);
        }
示例#3
0
        public override bool retainAll(java.util.Collection <Object> coll)
        {
            bool result = collection.retainAll(coll);

            if (result == false)
            {
                return(false);
            }
            else if (collection.size() == 0)
            {
                setOrder.clear();
            }
            else
            {
                for (java.util.Iterator <Object> it = setOrder.iterator(); it.hasNext();)
                {
                    Object obj = it.next();
                    if (collection.contains(obj) == false)
                    {
                        it.remove();
                    }
                }
            }
            return(result);
        }
示例#4
0
        public override bool removeAll <_T0>(java.util.Collection <_T0> collection)
        {
            bool result = false;

            if (size() <= collection.size())
            {
                java.util.Iterator <E> it = iterator();
                while (it.hasNext())
                {
                    if (collection.contains(it.next()))
                    {
                        it.remove();
                        result = true;
                    }
                }
            }
            else
            {
                java.util.Iterator <_T0> it = collection.iterator();
                while (it.hasNext())
                {
                    result = remove(it.next()) || result;
                }
            }
            return(result);
        }
示例#5
0
 public void remove()
 {
     if (lastReturned == null)
     {
         throw new java.lang.IllegalStateException();
     }
     if (root.fast)
     {
         lock (root)
         {
             if (expected != root.map)
             {
                 throw new java.util.ConcurrentModificationException();
             }
             root.remove(lastReturned.getKey());
             lastReturned = null;
             expected     = root.map;
         }
     }
     else
     {
         iterator.remove();
         lastReturned = null;
     }
 }
示例#6
0
        /**
         * Adds an addition change.
         *
         * @param pChange
         *            the change which should result in an addition
         */
        private void addAddition(Change pChange)
        {
            if (Change.TYPE_ADD != pChange.type() ||
                pChange.getInput() == null)
            {
                return;
            }

            if (!changes.isEmpty())
            {
                for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();)
                {
                    Change change = it.next();
                    if (change.type() == Change.TYPE_ADD && change.getEntry() != null)
                    {
                        org.apache.commons.compress.archivers.ArchiveEntry entry = change.getEntry();
                        if (entry.equals(pChange.getEntry()))
                        {
                            if (pChange.isReplaceMode())
                            {
                                it.remove();
                                changes.add(pChange);
                                return;
                            }
                            else
                            {
                                // do not add this change
                                return;
                            }
                        }
                    }
                }
            }
            changes.add(pChange);
        }
示例#7
0
 /**
  * Removes from the underlying collection of the base iterator the last
  * element returned by this iterator.
  * This method can only be called
  * if <code>next()</code> was called, but not after
  * <code>hasNext()</code>, because the <code>hasNext()</code> call
  * changes the base iterator.
  *
  * @throws IllegalStateException if <code>hasNext()</code> has already
  *  been called.
  */
 public void remove()
 {
     if (nextObjectSet)
     {
         throw new java.lang.IllegalStateException("remove() cannot be called");
     }
     iterator.remove();
 }
示例#8
0
 public void remove()
 {
     iterator.remove();
     if (values.isEmpty())
     {
         root.remove(key);
     }
 }
 public void remove()
 {
     if (tempIterator == null)
     {
         throw new java.lang.IllegalStateException();
     }
     tempIterator.remove();
 }
示例#10
0
 /**
  * Removes from the underlying collection the last element returned.
  * <p>
  * This method calls remove() on the underlying Iterator and it may
  * throw an UnsupportedOperationException if the underlying Iterator
  * does not support this method.
  *
  * @throws UnsupportedOperationException
  *   if the remove operator is not supported by the underlying Iterator
  * @throws IllegalStateException
  *   if the next method has not yet been called, or the remove method has
  *   already been called after the last call to the next method.
  */
 public void remove()
 {
     if (lastUsedIterator == null)
     {
         throw new java.lang.IllegalStateException("Iterator remove() cannot be called at this time");
     }
     lastUsedIterator.remove();
     lastUsedIterator = null;
 }
示例#11
0
 /**
  * Removes from the underlying collection the last element
  * returned by the Iterator.  As with next() and hasNext(),
  * this method calls remove() on the underlying Iterator.
  * Therefore, this method may throw an
  * UnsupportedOperationException if the underlying
  * Iterator does not support this method.
  *
  * @throws UnsupportedOperationException
  *   if the remove operator is not supported by the underlying Iterator
  * @throws IllegalStateException
  *   if the next method has not yet been called, or the remove method has
  *   already been called after the last call to the next method.
  */
 public void remove()
 {
     lockChain();
     if (currentIterator == null)
     {
         updateCurrentIterator();
     }
     lastUsedIterator.remove();
 }
 /**
  * Removes the last returned element from the child iterator that
  * produced it.
  *
  * @throws IllegalStateException if there is no last returned element,
  *  or if the last returned element has already been removed
  */
 public virtual void remove()
 {
     if (lastReturned == -1)
     {
         throw new java.lang.IllegalStateException("No value can be removed at present");
     }
     java.util.Iterator <Object> it = (java.util.Iterator <Object>)(iterators.get(lastReturned));
     it.remove();
 }
 public override void clear()
 {
     // override as default implementation jumps to [1]
     for (java.util.Iterator <Object> it = keySet().iterator(); it.hasNext();)
     {
         it.next();
         it.remove();
     }
 }
 public virtual void clear()
 {
     java.util.Iterator i = iterator();
     while (i.hasNext())
     {
         i.next();
         i.remove();
     }
 }
示例#15
0
 public virtual void clear()
 {
     java.util.Iterator <E> it = iterator();
     while (it.hasNext())
     {
         it.next();
         it.remove();
     }
 }
 public virtual void remove()
 {
     if (_parent.modCount() != _mods)
     {
         throw new java.util.ConcurrentModificationException();
     }
     _support.remove();
     _parent.remove(_current, 1);
     _mods++;
 }
 public override void clear()
 {
     checkModCount();
     java.util.Iterator <Object> it = iterator();
     while (it.hasNext())
     {
         it.next();
         it.remove();
     }
 }
        //-----------------------------------------------------------------------

        /**
         * Removes the last returned key from the underlying <code>Map</code>.
         * <p>
         * This method can be called once per call to <code>next()</code>.
         *
         * @throws UnsupportedOperationException if remove is not supported by the map
         * @throws IllegalStateException if <code>next()</code> has not yet been called
         * @throws IllegalStateException if <code>remove()</code> has already been called
         *  since the last call to <code>next()</code>
         */
        public void remove()
        {
            if (canRemove == false)
            {
                throw new java.lang.IllegalStateException("Iterator remove() can only be called once after next()");
            }
            iterator.remove();
            last      = null;
            canRemove = false;
        }
示例#19
0
 /**
  * Deregisters a cursor from the list to be notified of changes.
  *
  * @param cursor  the cursor to deregister
  */
 protected virtual void unregisterCursor(Cursor cursor)
 {
     for (java.util.Iterator <Object> it = cursors.iterator(); it.hasNext();)
     {
         java.lang.refj.WeakReference <Object> refJ = (java.lang.refj.WeakReference <Object>)it.next();
         Cursor cur = (Cursor)refJ.get();
         if (cur == null)
         {
             // some other unrelated cursor object has been
             // garbage-collected; let's take the opportunity to
             // clean up the cursors list anyway..
             it.remove();
         }
         else if (cur == cursor)
         {
             refJ.clear();
             it.remove();
             break;
         }
     }
 }
示例#20
0
 /**
  * Removes all nodes by iteration.
  */
 protected override void removeAllNodes()
 {
     if (size() > 0)
     {
         // superclass implementation would break all the iterators
         java.util.Iterator <Object> it = iterator();
         while (it.hasNext())
         {
             it.next();
             it.remove();
         }
     }
 }
示例#21
0
        //-----------------------------------------------------------------------

        /**
         * Registers a cursor to be notified of changes to this list.
         *
         * @param cursor  the cursor to register
         */
        protected virtual void registerCursor(Cursor cursor)
        {
            // We take this opportunity to clean the cursors list
            // of WeakReference objects to garbage-collected cursors.
            for (java.util.Iterator <Object> it = cursors.iterator(); it.hasNext();)
            {
                java.lang.refj.WeakReference <Object> refJ = (java.lang.refj.WeakReference <Object>)it.next();
                if (refJ.get() == null)
                {
                    it.remove();
                }
            }
            cursors.add(new java.lang.refj.WeakReference <Object>(cursor));
        }
        // Equals        // default object behaviour

        public virtual bool remove(object o)
        {
            java.util.Iterator i = iterator();
            while (i.hasNext())
            {
                object e = i.next();
                if (o == null ? e == null : o.Equals(e))
                {
                    i.remove();
                    return(true);
                }
            }
            return(false);
        }
        public void remove()
        {
            if (canRemove == false)
            {
                throw new java.lang.IllegalStateException("Iterator remove() can only be called once after next()");
            }
            // store value as remove may change the entry in the decorator (eg.TreeMap)
            Object value = last.getValue();

            iterator.remove();
            parent.maps[1].remove(value);
            last      = null;
            canRemove = false;
        }
示例#24
0
        public virtual bool retainAll <_T0>(java.util.Collection <_T0> collection)
        {
            bool result = false;

            java.util.Iterator <E> it = iterator();
            while (it.hasNext())
            {
                if (!collection.contains(it.next()))
                {
                    it.remove();
                    result = true;
                }
            }
            return(result);
        }
        //-----------------------------------------------------------------------
        public virtual bool retainAll(java.util.Collection <Object> coll)
        {
            bool modified = false;

            java.util.Iterator <Object> it = iterator();
            while (it.hasNext())
            {
                if (coll.contains(it.next()) == false)
                {
                    it.remove();
                    modified = true;
                }
            }
            return(modified);
        }
示例#26
0
        /**
         * Removes the first n entries in the map, where n is the number of entries in the map beyond its capacity. Note
         * that the entry set and the corresponding iterator are backed by the map itself, so changes to an entry iterator
         * correspond to changes in the map. We use the iterator's remove() method because we're removing elements from the
         * entry set as we iterate over them.
         */
        protected void removeOverCapacityEntries()
        {
            int count = this.size() - this.getCapacity();

            if (count <= 0)
            {
                return;
            }

            java.util.Iterator <java.util.Map.Entry <K, V> > iter = this.entrySet().iterator();
            for (int i = 0; i < count && iter.hasNext(); i++)
            {
                iter.next();
                iter.remove();
            }
        }
        public virtual bool removeAll(Collection c)
        {
            java.util.Iterator i = iterator();
            bool didremove       = false;

            while (i.hasNext())
            {
                object o = i.next();
                if (c.contains(o))
                {
                    didremove = true;
                    i.remove();
                }
            }
            return(didremove);
        }
示例#28
0
        public static bool removeIf(Collection @this, java.util.function.Predicate predicate)
        {
            java.util.Iterator i = @this.iterator();
            bool didremove       = false;

            while (i.hasNext())
            {
                object o = i.next();
                if (predicate.test(o))
                {
                    didremove = true;
                    i.remove();
                }
            }
            return(didremove);
        }
示例#29
0
 /**
  * Informs all of my registered cursors that the specified
  * element was just added to my list.
  *
  * @param node  the node that was changed
  */
 protected virtual void broadcastNodeInserted(Node node)
 {
     java.util.Iterator <Object> it = cursors.iterator();
     while (it.hasNext())
     {
         java.lang.refj.WeakReference <Object> refJ = (java.lang.refj.WeakReference <Object>)it.next();
         Cursor cursor = (Cursor)refJ.get();
         if (cursor == null)
         {
             it.remove(); // clean up list
         }
         else
         {
             cursor.nodeInserted(node);
         }
     }
 }
        public override bool removeAll(java.util.Collection <Object> coll)
        {
            if (parent.isEmpty() || coll.isEmpty())
            {
                return(false);
            }
            bool modified = false;

            java.util.Iterator <Object> it = iterator();
            while (it.hasNext())
            {
                if (coll.contains(it.next()))
                {
                    it.remove();
                    modified = true;
                }
            }
            return(modified);
        }