Two Iterators on the Same Collection

I posted this one on the Java Collections Framework forum but there don't seem to be many people there so let me post this here, too.
I want to use two iterators at the same time on a single collection. They are like two trains going one after another. If I use the iterator supplied by Java, however, if one iterator structurally modifies the underlying collection, the other throws ConcurrentModificationException.I want to avoid this. I want both iterators to modify the underlying collection freely, and when the collection was modified by one, I want the other to know what happened and what to do, rather than throwing an exception. How can I do this? Can I just manipulate somewhat on the Java iterator, or must I make an iterator implementation that does what I want from the scratch?

I'm writing a flow analysis module of a compiler. I'm not totally sure what optimizer does, but it needs to manipulate the list of instructions, which involves removing and adding instructions into the list. Some time we may need two iterators that cooperate together to find out when we can remove an instruction, for example. Or, one iterator does the analysis and removal, while the other may do some cleanup work. (I say again I'm not totally sure what optimizer does.) Some guy suggested using visitor pattern, but after some investigation (of the visitor pattern stuff) I thought iterator that behaved more smartly was more relevant. Or maybe not.

Similar Messages

  • Two iterators browsing the same data (a table and a tree) problem

    I have an ADF UIX application with a navigation tree and a central page with a table of the records of a Works view object.
    There is a hierarchical relationship of Works ->Subworks-> Tasks which is shown in the tree. In the central part of the page, there is a table of Works.
    I want
    1) the tree to show all the data, but only about 10 works at a time (using small arrows for scrolling up and down)
    2) the table to show only 10 or 20 records each time. Not the same with the tree.
    3) Both clicking on a link on the tree and selecting a work on the table will open the appropriate page.
    4) Opening the children of a node in the tree and clicking on the links being able to send me directly in the correct subwork or task page EVEN if I haven't visited the parent node (work) first.
    I cannot seem to be able to succed in the "even if" part of 4 and I can succeed in only any 2 of the first three.
    If the tree iterator and table iterator point to the same view object (work1 for example), it is impossible to show a different set of works in the tree and the table
    If I use different view objects, then, if the tree part is working, the table selection doesn't work. I imagined that's a problem with "SetCurrentRowWithIndex" and I tried to set up correctly a "SetCurrentRowWithKey" event, but I didn't know how to write the handler. (I use JHS event handling, by the way)
    I suppose the following has errors:
    <event name="setCurrentRowWithKey" source="GetaeergView1">
    <set target="${bindings.GetaeergView1Iterator}" property="currentRowKeyInRange" value="${ui:tableSelectedKey(uix, 'GetaeergView1')}"/>
    </event>
    Any suggestions?

    Noone has tried this again?

  • Can I transfer songs between two libraries on the same computer?

    I have two libraries on my computer, was wondering if any one knows a simple painless way to transfer music from one to the other.
    The reason is my music collection has gotten unfathomably large over the years, and I no longer want it to be that way. I was thinking maybe I could just find someway to "hide" a majority of the songs most of the time, and just show the ones i'm into at the moment. Since i couldn't find a way to do that, i made another entire library (both under the same user), thinking i would keep the bulk in one and the songs i was into for the moment in another, but have them linking to the same folder containing all the music files. This is working fine, but i would love an easier way to transfer the songs over to the favourites library, especially someway to do all the songs in a play list.
    Any ideas would be greatly appreciated
    Thank you!

    iTunes must be running for home sharing to work.  There is no way to have home sharing running simultaniously for two users on the same computer.
    Simply add the media files using File > Add File/Folder option in iTunes.

  • How do I put two galleries on the same page?

    What's the "trick" to putting two galleries on the same page?
    I've been experimenting, but it's not working out well. I have one working, but when I put the seond one on, all sorts of unexpected things happen. The first gallery goes up "over" the banner (it covers it??) and even though the sizes are spec'd the same, the second one shows up a lot larger as well.
    It's very weird.
    Any insight would be appreciated!
    Thanks!
    Michelle

    Juan,
    When Application Express finds a validation error, the page rendering step is executed again in the same database process used for the validations. So the procedure wwv_flow.accept, which is doing your validations, calls wwv_flow.show (a PL/SQL call) and passes information about the validation errors to the show procedure so that error text can be merged into the page rendering process.
    If you want to simulate this you might need to save validation info in collections and build the "show" part of the page so that it knows how to run in "validation-display" mode, i.e., to be able to use the collections.
    Scott

  • Why does the same collection keep doing soft pulls on my credit

    I have 2 soft pulls from the same collection. I don't want to call them and they are located in florida. I am located in CT. most of my previous collections were either from NY or CT. why don't they just call or mail me the bill to my house. I am also afraid to call because since they are doing soft pulls it might be a huge bill. The dates of the soft pulls are in Sept 2013 and Dec 2014. All this info came from annual credit report .com

    mwlcolorado wrote:
    Portfolio Recovery has been doing soft pulls on me at least 3-4 times a year for a debt from 2002(way outside the SOL.)  I'm not too concerned.  About once a quarter, they send me a settlement letter and I usually get a phone call every 6 months.  I've contemplated a couple times about settling with them (it's only $120ish) but then I think back to all the illegal crap they pulled and harassment I endured and just decided to say screw it.  Since it's out of the SOL, there isn't much they can do.  They can keep doing soft pulls and sending letters and I can keep putting them in the shred pile.Portfolio started soft pulling my file in May when I applied for a few cards. Since that date they soft pulled me almost every other day for two weeks straight. The last time I pulled a full report they were still doing soft pulls, though not as frequently. I haven't dealt with PRA in many years and panicked at first. But I have received no phone calls and no letters. So, I'll just let it be for now I guess. I have no collections. I honestly don't know what accounts they are collecting on. I find it annoying so perhaps I'll contact them at some point.

  • Two iterators - One view - Same page

    Hi, I have a big question...
    I have two iterator from the same view in one page, but when I re-execute the query from the view, it change both iterators. There's a way to make it without create a new viewObject for the second iterator?
    Here's my code:
    DCIteratorBinding iterator = (DCIteratorBinding)getBindings().get("iteratorOne");
    ViewObject voOne = iterator.getViewObject();
    voOne.setNamedWhereClauseParam("param", paramOne);
    voOne.executeQuery();
    DCIteratorBinding iterator = (DCIteratorBinding)getBindings().get("iteratorTwo");
    ViewObject voTwo = iterator.getViewObject();
    voTwo.setNamedWhereClauseParam("param", paramTwo);
    voTwo.executeQuery();
    Thanks

    This is my case of use, I have two combos of employes from the employeViewObject, but each combo is a diferent iterator from the same view, programmatic I pass a parameter (area) to the view and then I execute the query, but when I do it for one it make the change for the both combos, beacause it came from the same view.
    viewObject: EmpleadoSIRHPorAreaView
    iterator 1: EmpleadoSIRHPorAreaView1Iterator
    iterator 2: EmpleadoSIRHPorAreaView1Iterator1
    programmatc {
    DCIteratorBinding iterator = (DCIteratorBinding)getBindings().get("EmpleadoSIRHPorAreaView1Iterator");
    ViewObject empleadoVo = iterator.getViewObject();
    empleadoVo.setNamedWhereClauseParam("currentArea", valueChangeEvent.getNewValue());
    empleadoVo.executeQuery();
    Theres a way without make another view to execute the query just for one of them without affect the other iterator.
    Thanks

  • Telnet two devices at the same time 1 C# program

    Hi, currently I have one 100% working program used to telnet my Arduino circuit.
    I use this C# class found somewhere around the web: Anyway, without this forum, I wouldn't be able to finish my program.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Net.Sockets;
    namespace USSR
    enum Verbs
    WILL = 251,
    WONT = 252,
    DO = 253,
    DONT = 254,
    IAC = 255
    enum Options
    SGA = 3
    class TelnetConnection
    TcpClient tcpSocket;
    int TimeOutMs = 100;
    public TelnetConnection(string Hostname, int Port)
    tcpSocket = new TcpClient(Hostname, Port);
    public string Login(string Username, string Password, int LoginTimeOutMs)
    int oldTimeOutMs = TimeOutMs;
    TimeOutMs = LoginTimeOutMs;
    string s = Read();
    if (!s.TrimEnd().EndsWith(":"))
    throw new Exception("Failed to connect : no login prompt");
    WriteLine(Username);
    s += Read();
    if (!s.TrimEnd().EndsWith(":"))
    throw new Exception("Failed to connect : no password prompt");
    WriteLine(Password);
    s += Read();
    TimeOutMs = oldTimeOutMs;
    return s;
    public void WriteLine(string cmd)
    Write(cmd + "\n");
    public void Write(string cmd)
    if (!tcpSocket.Connected) return;
    byte[] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(cmd.Replace("\0xFF", "\0xFF\0xFF"));
    tcpSocket.GetStream().Write(buf, 0, buf.Length);
    public string Read()
    if (!tcpSocket.Connected) return null;
    StringBuilder sb = new StringBuilder();
    do
    ParseTelnet(sb);
    System.Threading.Thread.Sleep(TimeOutMs);
    } while (tcpSocket.Available > 0);
    return sb.ToString();
    public bool IsConnected
    get { return tcpSocket.Connected; }
    void ParseTelnet(StringBuilder sb)
    while (tcpSocket.Available > 0)
    int input = tcpSocket.GetStream().ReadByte();
    switch (input)
    case -1:
    break;
    case (int)Verbs.IAC:
    // interpret as command
    int inputverb = tcpSocket.GetStream().ReadByte();
    if (inputverb == -1) break;
    switch (inputverb)
    case (int)Verbs.IAC:
    //literal IAC = 255 escaped, so append char 255 to string
    sb.Append(inputverb);
    break;
    case (int)Verbs.DO:
    case (int)Verbs.DONT:
    case (int)Verbs.WILL:
    case (int)Verbs.WONT:
    // reply to all commands with "WONT", unless it is SGA (suppres go ahead)
    int inputoption = tcpSocket.GetStream().ReadByte();
    if (inputoption == -1) break;
    tcpSocket.GetStream().WriteByte((byte)Verbs.IAC);
    if (inputoption == (int)Options.SGA)
    tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WILL : (byte)Verbs.DO);
    else
    tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WONT : (byte)Verbs.DONT);
    tcpSocket.GetStream().WriteByte((byte)inputoption);
    break;
    default:
    break;
    break;
    default:
    sb.Append((char)input);
    break;
    My UI Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Net.Sockets;
    namespace USSR
    public partial class mainForm : Form
    TelnetConnection tc;
    public bool keyPressChecker = false;
    public bool connectedChecker = false;
    public mainForm()
    InitializeComponent();
    // webBrowser1.Navigate("http://admin:[email protected]");
    this.tc = null;
    this.connectedChecker = false;
    private void radioButton2_CheckedChanged(object sender, EventArgs e)
    try
    if (submarineRadioBtn.Checked)
    System.Diagnostics.Process.Start("dummySub.exe");
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void centerBtnCamera_Click(object sender, EventArgs e)
    private void forwardBtn_Click(object sender, EventArgs e)
    if (connectedChecker)
    this.tc.WriteLine("W");
    private void connectToolStripMenuItem1_Click(object sender, EventArgs e)
    try
    //create a new telnet connection
    tc = new TelnetConnection("192.168.0.102", 23);
    if (tc.IsConnected)
    connectedChecker = true;
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void controlKeyDownCheckBox_CheckedChanged(object sender, EventArgs e)
    if (controlKeyDownCheckBox.Checked == true)
    keyPressChecker = true;
    else
    keyPressChecker = false;
    private void controlKeyDownCheckBox_KeyDown(object sender, KeyEventArgs e)
    if (keyPressChecker == true)
    if (e.KeyCode == Keys.W)
    if (connectedChecker)
    tc.WriteLine("W");
    if (e.KeyCode == Keys.S)
    if (connectedChecker)
    tc.WriteLine("S");
    private void reverseBtn_Click(object sender, EventArgs e)
    if (connectedChecker)
    tc.WriteLine("S");
    private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
    try
    tc = null;
    connectedChecker = false;
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void controlKeyDownCheckBox_KeyUp(object sender, KeyEventArgs e)
    if (keyPressChecker == true)
    if (e.KeyCode == Keys.W)
    if (connectedChecker)
    tc.WriteLine("O"); //decrease to MID PT.
    if (e.KeyCode == Keys.S)
    if (connectedChecker)
    tc.WriteLine("P"); //decrease speed to MID PT.
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    Application.Exit();
    Now, what I want to know is this: IS IT POSSIBLE FOR MY C# PROGRAM TO TELNET TWO DEVICES AT THE SAME TIME? 
    Thanks
    Glenn

    try this links :
    http://www.codeproject.com/Articles/19071/Quick-tool-A-minimalistic-Telnet-library
    http://stackoverflow.com/questions/25116077/send-and-receive-commands-via-telnet-in-c-sharp
    http://stackoverflow.com/questions/12283241/ssh-to-server-then-telnet-to-device

  • Write a progarm to test two parts at the same time

    Hi:
    I need to write a program in LabView that is capable of testing two parts at the same time.
    Explanation:
    I star the test on a unit, once all the electrical test is done move that unit to the pressure test without loosing the current test information and continue the test of the unit thewn generate a serial number only if it passes all the test. Then while the previous unit is going thru the pressure test star testing another unit for the elecrical test and so on.
    I am using LabView 2012

    From what you have described, I agree with what has been answered above. TestStand is specifically designed for. If you would like to provide more information about your application we could give you a more detailed response. For more information about TestStand follow this link
    www.ni.com/teststand
    Ryan
    Ryan
    Applications Engineer
    National Instruments

  • Is there a way to add two windows in the same window?

    is there a way to add two windows in the same window?

    what do you mean by your first use of the word "window"? do you mean a visible frame? a section of the gui that the user doesnt see?
    or perhaps you mean you want to add multiple tabs to a single window, so that switching between tabs shows different windows?

  • Is there a way to show two angles at the same time in the final edit rather than switch between them with Multicam?

    Can I show two angles at the same time in the final edit rather than alternate with Multicam?

    Stack two clips on top of each other and reduce the sizes. I think that's what you want.

  • In iPad 1 ios 4 may have two ipad Apps the same from two accounts itunes

    In iPad 1 ios 4 may have two ipad Apps the same from two accounts itunes one free other paid account, hence one free App and another paid App the same App?

    If both accounts are authorised on your computer's iTunes (Store > Authorise This Computer) then you can download the books from both accounts to there (download the books from one account, then sign out of it via Store > Sign Out, log in with the other account via Store > Sign In and download the books from the other account), and sync them over to the iPad's iBooks app via the Books tab.
    Or you might be able to sign out of your account on the iPad by tapping on it Settings > Store and sign in with the other account and download the books from that account - I think that it should work, but it's not something that I've tried so I'm not 100% sure that it will

  • Print data in two line in the same column

    Hi,
    In a tabular Report I want to print a column (eg:Description,) in two lines in the same cell.
    Since the description is too long. Is it possible in report 6i. Or any other solution for this?
    Please reply.

    Hello,
    For the Description field set the Vertical Elasticity to EXPAND. Then it will adjust automatically based on data.
    -Ammad

  • How do I share one itunes account between two users on the same computer

    How do I share one itunes account between two users on the same computer without taking up twice as much space on my hard drive?

    You would need to move the itunes folder to a location that both users have permissions to access such as the Shared folder or any folder on the root level of the macintosh HD.
    You can find instructions here http://support.apple.com/kb/HT1203 This method allows you to share the content without sharing the same library.

  • Can two people share the same Apple ID on two different iPhones and maintain different passwords?  Yes, there is more to the story.

    I have an iMac, and iPhone.  I've had my Apple ID for a few years. 
    My wife got an iPhone 4S a few months back and the salesperson at Verizon set her Apple ID the same as mine, but gave her a different password.  I don't know if this was ok, but that is what happened.
    So, yesterday, we both upgraded to IOS6 and I had no problem logging in to my iPhone with my Apple ID.  When my wife went to log in, she was told that she was entering the wrong password. We entered the password over and over again and still was wrong.
    The question is... can two people share the same Apple ID on two different iPhones and maintain different passwords?  (I have the feeling her iPhone is thinking that since it's my Apple ID, it wants my password.)
    If not, can I still set up a new Apple ID for her even through she's had the iPhone for a few months?
    Thanks.

    Hi
    You shold follow your feelings, its probably right most of the time.
    You can have 5 different devices hucked upp to one Apple ID. What I have done is that my wife and I have one Apple ID, when I bye a new app on my phone, She gets it to. Thats nice.
    You can allways set upp a new Apple ID for your wife.

  • Hello there - how can I share my iTunes library between two users on the same computer? I put the library in a shared folder between both and have selected this library on both as well, but when I update iTunes with music etc it only appears on one?

    Hello there - how can I share my iTunes library between two users on the same computer? I put the library in a shared folder between both and have selected this library on both as well, but when I update iTunes with music etc it only appears on one?

    Thank you Joe - I tried this but it's only showing a teensy amount of music - the stuff on the second users account as opposed to the giagntic library on the 'main' account. I actually went to a Genius Bar and they said that apple doesn't really want you to share music between accounts - parents don't want to hear their kids music etc. Which seemed strange, but it might be the case sadly   Thanks anyway!

Maybe you are looking for

  • After 4.3, iTunes no longer opens when I plug my iPhone in to sync

    I downloaded the most recent update. Now, when I plug in my iPhone to sync/charge, only iPhoto opens and iTunes will not.  I have the box checked in iTunes to open iTunes when the phone is connected but it doesn't and I have to open it manually.  Bug

  • Import data from Oracle table into flat file

    How to import the data in the oracle table into flat file using UTL File of PL/SQL.... I am new in PL/SQL.. can someone help me in writing query?

  • RAID won't mount until 20 minutes have passed

    Every now and then I'll have a crash on my G5. If I have to force quit through menus or manually through power my RAID won't mount after the restart. The RAID is a striped 5 hard drive set at RAID 0. After some turning on and off of the RAID and plug

  • SEM-CPM docs

    Hi, Can anyone provide me with any docs related to SEM-CPM module. I am actually looking for some documentation which explain WITH EXAMPLES. Thanks in advance, Points are assured.

  • Is the iphone 4S bought in US compatible to use in Singapore

    Hi,      I have this URGENT question as i would like to purchase the lastest Iphone 4S but i do not know whether it is compatible to use in Singapore.Thank You for your help. Regards, Leong