remove « iterator « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » iterator » remove 

1. Is iterator.remove() is ROBUST in all cases in java?    stackoverflow.com

As in C++ iterator.remove() is not 100% safe or robust does java guarantees 100% robustness with iterator.remove()?

2. why iterator.remove() has been described as optional operation?    stackoverflow.com

i went through the documentation(http://java.sun.com/javase/6/docs/api/java/util/Iterator.html) of Iterator.remove() there remove() was described as

void remove()
Removes from the underlying collection the last element returned by the iterator (optional ...

3. Design pattern for adding / removing elements    stackoverflow.com

Wikipedia's definition for Iterator pattern design: the Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying ...

4. does using remove on iterator makes code to work very slow?    stackoverflow.com

I have a code as follows, it uses remove on a iterator as show:

Collection<X> getdata(){
   Collection<X> Xs = this.getXs();
    Iterator<X> iterator = Xs.iterator();
    ...

5. Removing items in an iterator    coderanch.com

Consider the following code: final Collection items = ... final Iterator i = items.iterator(); while(i.hasNext()) { final Object item = i.next(); // Do something with each item // The code in question: i.remove(); } Now, add the specification that items is quite large in memory (~1 million items), the loop takes 5 minutes to execute, and after an item is used ...

6. Using Iterator.remove()    coderanch.com

When running this shuffler program I expect to get five random objects and then a null at the end. But I`m getting six objects in output when I got 5 declared. I think it`s because I don`t know how to use the Iterator.remove() method properly. Here`s the code: import java.util.* ; public class Shuffler { public static void main(String[] args) { ...

7. Iterator add and it.remove();    coderanch.com

you just described what works, not where the problem lies (Exceptions ? unexpected result ?), how you call the code and so on. Perhaps the problem has anything to do with the local variable "members" which also exists as a property of the Club class ? And since you pass in month and year in the purge() method i assume you ...

8. Iterator.remove()    coderanch.com

9. remove from Iterator    coderanch.com

10. for-loop & iterator.remove()    forums.oracle.com

11. How to remove the element with Iterators    forums.oracle.com

I have a programm like this Vector ts = new Vector(); ts.add("abc"); ts.add("abd"); Iterator it = ts.iterator(); ts.remove("abc"); it.remove(); while(it.hasNext()) { System.out.println("val = " + it.next()); } What is the problem if I use remove with iterator. It is giving the error java.lang.IllegalStateException. Can somebody tell me what is wrong with this.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.