Uniqe object in list

Hi. I have a program something like below.
List<Edge> openEdge = new ArrayList<Edge>();
List<Edge>closedEdge = new ArrayList<Edge>();
openEdge.add(e);  // e is a edge object
while(openEdge.size() > 0){
     Edge process = openEdge.remove(0);
     if(!closedEdge.contains(process){
           closedEdge.add(process);
     if(//ceratin condition met){
           List<Edge> outList = graph.getNode(process.getStartid).getOutList();
          for(int i = 0; i < outList.size(); i++){
               Edge relax = outList.get(i);
               if(!openEdge.contains(relax)){
                      openEdge.add(relax);
}I want my entries in openEdge and closedEdge without duplicate entry, I mean openEdge and closedEdge can have same Edge entry, but within the same list, duplicate entry is not allowed. I know java API provides Set implementation such as HashSet and LinkedHashSet.
But the problem I am facing is, I want to remove the Edges from the list in the order of their insertion.
Using List is not a problem at all. However, when i have a huge number of entries for each list, the computational time degrades and program becomes very slow.
The openEdge list entries go around 20,000.
What i did to make the program faster was i created two hashset and used it to prevent the insertion of same entry. This makes the program fast, but requires extra memory to hold the HashSet.
Is there a better solution for this? The closedEdge always starts with 0, and openEdge with 1, and the entries is of around 20,000. The contains method is making the program very slow as it requires checking the whole list,in worst case, each time in the insertion procedure.
Any advice on how to go on with this.
Thank you.

Let's see if posting this message finally works (fcking slow forum today!)
If you try it like this, it should get considerable improve the speed:
class EdgeList {
    private Set<Edge> edgeSet;
    private List<Edge> edgeList;
    public EdgeList() {
        edgeSet = new HashSet<Edge>();
        edgeList = new ArrayList<Edge>();
    public void add(Edge e) {
        if(edgeSet.add(e)) { // true if edgeSet did not already contain 'e'
            edgeList.add(e); // will be in order of insertion
    public List<Edge> getEdges() {
        return edgeList;
class Edge {
    // don't forget tho override the equals(...) and hashCode() methods!
}

Similar Messages

  • Services for Objects Attachement List Display Note not Viewable

    Hi Experts!
    Good day! I'm trying to display a note in FK03 (related to Services for Objects - Attachment List) and I only see white screen pop up window. No message and text information. When I tried to use another PC I can successfully view it.
    Is there's a plugin that I may need to install?
    Your help will be greatly appreciated.

    Hi Marty
    It is my understanding that the IXOS licensing is based on users retrieving of documents not necessarily the viewer so the licensing implications of having non-IXOS viewers accessing documents using the generic archivelink viewer is still likely to result in licensing implications if an audit is conducted at any stage.
    The transaction for specifying the viewer is the OAA3 and OAG4.
    Regards,
    Athol

  • UnsupportedOperationException Error while removing object from List

    Hi,
    I need to remove a set of objects from List if it contains similar objects as the other one.
    Follwing is the code snippet of the above scenario...
    List selectedPaxList = new ArrayList();
    TreeSet seatAssignedPaxlist= new TreeSet();
    selectedPaxList.add("1");
    selectedPaxList.add("2");
    selectedPaxList.add("3");
    seatAssignedPaxlist.add("1");
    seatAssignedPaxlist.add("2");
    if(selectedPaxList.containsAll(seatAssignedPaxlist))
    selectedPaxList.removeAll(seatAssignedPaxlist);
    If i do this in java program it executes fine without any error.But if I do the same in JSP I am getting the following error......
    java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(AbstractList.java:167)
    at java.util.AbstractList$Itr.remove(AbstractList.java:432)
    at java.util.AbstractCollection.removeAll(AbstractCollection.java:351)
    Plz... help me to resolve the issue

    java.lang.UnsupportedOperationException
    at
    java.util.AbstractList.remove(AbstractList.java:167)
    at
    java.util.AbstractList$Itr.remove(AbstractList.java:43
    2)
    at
    java.util.AbstractCollection.removeAll(AbstractCollect
    ion.java:351)
    That stack trace looks wrong to me.
    ArrayList overrides the remove method, so it
    shouldn't be using the method in AbstractList. That's what I thought, too. There is either something missing or it's not an ArrayList. In fact the javadoc of AbstractList.remove sais:
    "This implementation always throws an UnsupportedOperationException."
    So it really looks like another subclass is used.
    Also
    the object it is trying to remove is a list (from
    your exmaple it should be a String)
    I could be wrong.These are just the code references not the parameters, I think.
    -Puce

  • Is there a way to add new objects to object changeability list?

    My production system is locked and I need to change object type RSFO (formula). I looked at the object changeability list and it does not contain RSFO. Is there a way to add this object to this list so I can change it directly in production? Thanks.

    hi,
    I hope you can create similar formula in the production. as in the production we can change the reports,proces chain,aggregates, infopackages.
    Ramesh

  • Adding objects to list

    Hi,
    I am new java. I have a probelm adding objects to list. This is the following code.
    class Test{
    List <>dataList = new ArrayList<>();
    public List<A> getAList(){
    dataList.add(new A());
    return dataList ;
    public List<B> getBList(){
    dataList.add(new B());
    return dataList;
    }In the above code what I will pass<parameterized data> to the dataList decalred as member variable?

    bhanu wrote:
    nothing common for A and B. Both A and B are different pojos. but we can tell A and B extends from Object.I tried like that
    way. But it is not working. <? extends from Object>.Both two methods have to be in the same classYou do in that case have a bad design. Why is the same list used for both. It can't be type safe so you need to cast and the user of the list might get classcast exceptions during iteration.
    Kaj

  • When can we expect a patch for Object Array List Data Provider?

    Hey JSC Team!
    When can we expect maybe, just maybe a minor patch for the Object Array List Data Provider loading class problem? Next Month? This Year? Next Year? Near Future? Long in the future? Sometime in the 22nd century?

    I think one of the problem is
    when u declare the ObjectListDataProvider in ur backing bean
    it doesnt appear in the design time straight away
    u have to clean build close and re open the project
    which is quite time consuming.

  • Cannot Cast List ? extends Object as List Object

    I apologize if this is a common question but I could not seem to find the proper set of search terms that yielded an answer.
    Basically I have an RMI application and on the 'middle-tier' I would like to pass around references to the implementation objects and only convert to the interface type when dealing with them over RMI (I never pass an object back to the middle-tier).
    public interface Questionnaire implements Remote {
        public List<? extends Comment> getComments() throws RemoteException;
    public class QuestionnaireImpl extends UnicastRemoteObject implements Questionnaire {
        public List<CommentImpl> getComments() {...}
    }This works fine, the issue arises when I try to do the following:
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
        return classLoader.getQuestionnaire(questionnaireId).getComments();
    }The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.

    public List<? extends Comment> getComments() throws RemoteException;
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
    return classLoader.getQuestionnaire(questionnaireId).getComments();
    The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.Yes, however Java's generics work correctly to prevent you from shooting yourself in the foot. If you have a List<Superclass> pointing at a List<Subclass>, you would be entirely within your rights to try to store an object that is not castable to Subclass in it, this breaks type safety, so the compiler will not let you do it.
    Instead, create a new List<Supertype> and copy over the elements from the list returned by getComments(). There is a constructor that will do this for you.

  • Reference object structure list iam getting only functional location no

    Dears
    There is one query from our client that in reference object structure list he is getting only functional location no and not functional location description.i asked him to go to menu settings field selection -functional location and from the choose list  ask him to select functional location description .But still he couldn't get the required one. Can any body tell me the reason.

    Hi,
    You can achieve it from OIAJ tcode and set the required setting for your field IFLO-PLTXT.
    Regards,
    Keerthi

  • Looking for a better design: how to populate db result to object with lists

    I have a query that returns from the db an arrayList of class CarBean:
    carID, model, color, rentUserID, fname, lname, dateRentStart, dateRentEndThe query is with reference to a particular car that N people (rentUserID) rented and the user (the system user) wish to know how many rentals were made for this carID.
    I wish to populate the result into ONE class name CarRental which looks like this:
    private Car; //model
    private List<RentUser> rentals; //all info relating to rentUserso, my question is this, what creative way (Design Pattern, maybe?) is there to populate all the objects (CarBean) from the arrayList into CarRental?
    In my solution I'm doing something like this:
    Iterator<CarBean> itr = list.iterator();
    CarRental carRental = new CarRental();
    List rentals = new ArrayList();
    while (itr.hasNext())
        CarBean cb = itr.next();
        carRental.setCarID(cb.getCarID);
        //for the list of users:
       User u = new User(); 
       u.setUserID(cb.getUserID()); 
       rentals.add(u);
    carRental.setRentals(rentals);* please consider a more complicated query that the end result of ONE object should have X arrayList and other M objects in it
    thank you!

    Just to make sure I understand, here's a simple version of your question. Please correct anything I have wrong.
    Your design will have two classes: Car and Renter. A Renter is a Person who rents a Car on a given day:
    package model;
    public class Renter implements Serializable
        private Long id;
        private String name;
        private Address address;
        // Details left for you.
    }You'll also have a Car:
    package model;
    public class Car implements Serializable
        private Long id;
        private String make;
        private String model;
        private int year;
        // Details left for you.
    }It sounds like you want to have a one-to-many relationship between Car and Renter. I think you have a couple of choices:
    You can embed a List<Renter> as a data member inside the Car class, or
    You can encapsulate the relationship between a Car and a Renter in a separate class like a Contract.
    I kinda like the second option because it reifies a nice concept.
    As far as the database goes, I'd recommend following an idiom from Spring- their RowMapper interface:
    package persistence;
    public interface RowMapper
        Object map(ResultSet rs);
    }Encapsulate the mapping from ResultSets to Objects that way.
    Or use Hibernate, TopLink, or another ORM tool.
    %

  • Error while creating ADD-ON in objects check list

    Hi Experts,
    While i am creating Add-on i got error like below in SSDC while checking in Objects list.
    Help me for this .
    Thanks
    J Jana

    Hi,
    check below
    Error while installation of Addon
    http://forums.sdn.sap.com/search.jspa?threadID=&q=ExceptionfromHRESULT%3A0x8007000B%22windows+7&objID=f56&dateRange=all&numResults=15&rankBy=10001
    Exception from HRESULT: 0xFFFFE4A0
    Regards
    Deepak Tyagi

  • Attach PDF to PO object services list works for ME23N but not ME22N

    Manualy attach a PDF file from users PC to a PO. The attachment works for ME23N as described in SAP documentation for creating an attachment to the object services attachments list.
    When ME22N is used the "attachment created"  message displays but exiting the PO and reenter ME22N and the attachment is not saved in the services attachment list.
    Where is the configuration for this object service attachmentS?
    What is needed for ME22N that is different than ME23N?

    Hi,
    I don't think any difference b/w these 2 Transaction related to attachment of document through Services for Object.
    If you have the authorization for ME22N transaction definitely you can attachment any document both in ME22N & ME23N transaction throught this Services for Object.
    Check once again.If still you face the problem discuss with your Basis Consultant
    rgds
    Chidanand

  • VF03 - Services of Object - Attachment List - Send Email

    Dear All,
    I have following requirement and need help on this.
    Step1: Go the Transaction code u2018VF03u2019, give the Billing document and press u2018Enteru2019.
    Step2: In the next screen, we will be on the screen u2018Standard Invoice XXXXXXXX (ZSOR) Display: Overview of Billing Itemsu2019.
    In this screen, click Icon u2018Services for Objectu2019 (just below u2018Enteru2019 Icon). We will find the popup consists of Create, Attachment List, Private note, Send, Relationships, Workflow, My Objects and Help for object services.
    Click u2018Attachment Listu2019, popup appears consists of attached documents. This documents need to be attached and send via email to the specific person.
    Need inputs on the above requirement.

    User will execute VF01/VF02 and would like to see the email will generate along with the billing document for the output type ZRDO to ZRD4.
    Even if he executes the VF31 also, functionality will work to send the email along with the attachments.

  • ALV object model - List download

    H Experts,
    I have used ALV object model to list display.
    Also i have used class CL_ALV_COLUMNS_TABLE and its method set_long_text to set the column heading.
    Now if i execute this report, long text is displayed properly in column heading.
    But when i download this report output in spreadsheet, short text is displayed in column heading which is taken from the data element in DDIC.
    Example:
    I have declaed a column of type ABWTG.
    I have set leng text as 'TEST'.
    When i execute the report, column heading is displayed "TEST', which is as expected.
    But when i download this report in spreadsheet, column heading is displayed as 'NUMBER' in spread sheet. While downloading column heading is taken from the data element for field ABWTG. But i want the long text 'TEST' to be displayed when the report output is downloaded.
    Please suggest how to do it.
    Regards

    Hi,
    As per my understanding , it is displaying in excel based on ur ddic_output_length field.
    only becoz of that field it will show the same header.
    IF u will change the value at run time for this field then u will not get that issue,
    I m also searching on the same issue.
    Thanks
    Rahul

  • Can we put the bunch of object into List ?

    List.add(int indexkey , Object obj.)
    Class Customer
    here my question is that ... can we put the bunch of Customer object like : c1, c2 , c3 into List as object as a second argument with single index .. ???

    You can't do that. What you can do is insert in your list an Costumer array ...
    List myWeirdCostumerList = new ArrayList();//I like ArrayList. Pick your preffered one...
    Costumer[] myCostumers = new Costumer[x];
    //fill your array
    myWeirdCostumerList.add(indexKey, myCostumers);...or even another list of Costumer
    List myWeirdCostumerList = new ArrayList();//I like ArrayList. Pick your preffered one...
    List myCostumers = new ArrayList();
    myCostumer.add(new Costumer(...);
    myCostumer.add(new Costumer(...);
    myCostumer.add(new Costumer(...);
    //...keep filling
    myWeirdCostumerList.add(indexKey, myCostumers);But, as georgemc said, you may be in trouble retrieving a certain Costumer object...

  • SSMS is not listing table and views objects though the objects are listed when I execute TSql string "SELECT * FROM sys.Tables"

    I have a db, call it xyz.mdb
    It suddenly is that SSMS is not listing the table objects nor the Views.  SELECT * FROM sys.Tables and SELECT * FROM sys.Views work very fine.  But when I click on the tables node, on Objects Explorer, Only the Systems Tables and File Tables folders
    show. 
    Other DBs on same SQL instance do not show same problem.  They are all working very fine.
    I have backed up and restored this db on other computers and the behaviour is the same.  Incidentally right-clicking the db and clicking Properties throws up this error message.
    -------------------------------------------------------------------------Error!
    Cannot show requested dialog.
    Property Size is not available for Database '[Pliny E DB - NOA 2014]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.  (Microsoft.SqlServer.Smo)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1325+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.PropertyCannotBeRetrievedExceptionText&EvtID=Size&LinkId=20476
    --------------------------------------------------------------------------------End>
    When I try to Refrresh the Tables node on Object Explorer, I get this other:
    ------------------------------Error!
    SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0x9090d9b7; actual: 0x909001b4). It occurred during a read of page (1:1173) in database ID 21 at offset 0x0000000092a000 in file 'c:\Databases\Clients\NOA\Pliny E DB -
    NOA 2014.mdf'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check
    (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. (Microsoft SQL Server, Error: 824)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476
    ------------------------------End>
    The Help link of course is not valid any more.
    Many thanks
    Vie
    @Abuja
    Vie

    Your database is corrupted and you need to run.
    DBCC CHECKDB
    You already have a backup so do it...
    This link will provide you with more information:
    http://msdn.microsoft.com/en-us/library/ms176064.aspx

Maybe you are looking for

  • What is the best way to export a slideshow .I like to show my slideshows via appleTV on my TV

    What is the best way to export a slideshow.I like to view  the show trough AppleTV on my television.

  • Installer hung -- M$ Office 2011 on my new iMac.

    Hello, Totally new Mac newbie here.  I am trying to install M$ Office 2011 on my new iMac. The installer process stopped on the "installation" step and said I needed to quit Safari and Firefox before it could continue.  I did quit those apps (at leas

  • Calculating a pie wedge

    Ok I stuck, I have tried several different equations and I can't seem to get this one. int[]  totalAnswersForAnswer totalAnswersForAnswer[0] = 2 totalAnswersForAnswer[1] = 3 totalAnswersForAnswer[2] = 2 totalAnswersForAnswer[3] = 2 totalAnswersForAns

  • OS X and classic on Cube?

    I never had any system discs for my Cube. I've alternately run OS9 and X on the Cube and recently thought it should be a dedicated 9/X computer (OSX and classic). I have system discs for iMac 800, PM G4 450 AGP, and PM MDD Dual 1G, none of them will

  • Claimed up to date mountain lion

    I applied for an uprgrade to Mountain Lion and was given a reference number and told I would receive an email. I've heard nothing. Any news about how I go about upgrading? I only bought my macair last week.