list « 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 » list 

1. iterator for replacing list members in Java?    stackoverflow.com

Hmmm... the Java Iterator<T> has a remove() method but not a replace(T replacement) method. Is there an efficient way to replace selected items in a List? I can use a for-loop to ...

2. Cloning iterators in Java    stackoverflow.com

I have a LinkedList in Java, an iterator to browse the list and I would like to clone the iterator to do some temporary "look ahead" processing of the list with ...

3. Is there an easy way to copy an iterator into a list in Java?    stackoverflow.com

I want something like this:

public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
    List<Foo> fooList = new ArrayList<Foo>();
    fooList.addAll(fooIterator);
}
which should be equivalent to:
public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
   ...

4. Some bad code to look at -- Is it ok to iterate over a list within another iteration of the same list (N^2)?    stackoverflow.com

I have some objects in an arraylist and I want to perform collision detection and such. Is it ok to do something like:

List<Person> A;
iterA0 = A.iterator();
while (iterA0.hasNext()) {
    ...

5. Storing an Iterator Reference    stackoverflow.com

I have a Linked List that holds contact information(name, date of birth, etc...). I add the contacts in the list into the List. I want to use the iterator to go ...

6. List.iterator() or List.size()    coderanch.com

I have a List and I want to Iterate the elements and I can do it in either way. for(Iterator it=list.iterator();it.hasNext() ;) { // my processing with it.next() } or for(int i=0;i < list.size();i++) { // Processing with list.get(i) } which one should be preffered ?? thanks Shailesh [ February 04, 2005: Message edited by: Shailesh Chandra ]

7. List Iterator and If statement    coderanch.com

In the code below I am trying to iterate through a list and call a method from the currently referenced object "If" its variable nRefId matches the nRefId of the calling object. void processMessage(List cF){ Iterator it = cF.iterator(); while (it.hasNext()){ Field myObj = (Field)cF.next(); // Class name = Field If(myObj.nRefId = nRefId){//<<-- My problem myObj.print(); // Call to method in ...

9. List Iterator error - please explain    coderanch.com

import java.util.*; public class ListExample { public static void main(String[] args) { // declaration List list = new ArrayList(); Iterator elements = list.iterator(); // als some elements to the list list.add("one"); list.add("second"); list.add("3rd"); list.add(new Integer(4)); list.add(new Float(5.0F)); list.add("second"); // duplicate element, is added to list list.add(new Integer(4)); // duplicate, is added // Print contents of the list while (elements.hasNext()) { System.out.println(elements.next()); ...

10. How do you determine the index of a List Iterator?    forums.oracle.com

Element(0) Element(1) Element(2) ... Element(n) ^ ^ ^ ^ ^ Index: 0 1 2 3 n+1 But I don't know how to return an index of a List Iterator. I'm trying to build a nextIndex and previousIndex method, which would return the index of the particular List Iterator of either the next() or previous() functions had been performed. Here is the ...

11. Two iterators in one list??    forums.oracle.com

Yes. Assign the two iterators to two different variables, then work with the variables. At least your code would be readable if you do that; it still might not work in practice because modifying the list via one iterator may cause the other iterator to throw an exception. But give it a try.

12. Display list on one line using the iterator    forums.oracle.com

I need to diplay the list on one line using the itrator. This is what I have and it prints each name in the list on the next line. How can I modify this to get it to print on one line? Iterator listIter = theList.iterator(); while ( listIter.hasNext() ){ System.out.println( listIter.next() ); }

13. looking ahead in the list with iterator    forums.oracle.com

15. Custom iterator for custom list. ClassNotFoundException()    forums.oracle.com

I haven't fixed the above problem as of yet, but I have found 2 bugs in my add() and addNewChunk() methods. firstly the head is always null, head.link is null. add does not add data into head.data[elements], it skips straight to tail.data[elements]. Secondly elements 0-6 were only being filled up not, 0-7 so I was a little short. edit: was looking ...

16. Custom iterator for custom list.    forums.oracle.com

17. List Iterator    forums.oracle.com

Hello Forum, can some one help me on the following issue, issue is I have an unknown list but i need to pass 20 elements each time to execute stored procedure, so for the first time first 20 items(0-19) of List are picked and next time the next 20 items i.e. (20 - 39) and so on how can i do ...

18. Need help with lists and iterators    forums.oracle.com

I'm just starting out with java and I need some help figuring out some things. Say I have this class Node, and one of its fields is a list of Nodes. public class Node { private String nume; private Node parinte; private List fii = new ArrayList(); ...... Now in a different class - Helper -I need to analize each node ...

19. List iterator innerclass    forums.oracle.com

Ok I figured this out, after a hours of fooling around and getting nowhere with this minutes after I post. In the iterator() methods of the class if change the return type to iter the inner class I don't get errors when calling other inner class methods. DOH. I think I get it now. I am still confuse about why there ...

20. Iterator and List sorting    forums.oracle.com

22. List Iterator    forums.oracle.com

Okay hello everyone. i am having trouble with the list iterator methods. i have created and iterator of Video. Iterator

23. Value List Iterator pattern - Heapdump    forums.oracle.com

Hello, we are using the Value List Iterator pattern where we are instantiating a Transfer Object for each row in our Result Set. We are then setting all Transfer Objects into an ArrayList and returning back to our backing bean for display on screen. The problem is, some queries the users are running are bringing back 50,000 rows, which is causing ...

24. List iterator    forums.oracle.com

25. Iterator on List?    forums.oracle.com

As you answered that iterating thru linked list is O (N) and get method is O(N^2) while for arraylist is O(N). My question is 1) How should i interpret O(N). i mean something like this it will take n unit of time for iterator while N^2 for get operation? 2) Is there any way to derive these formulas for N number ...

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.