Return to Snippet

Revision: 10015
at December 3, 2008 11:32 by theobriscoe


Initial Code
// REMOVE: Any items that are not in the temporary list should be removed
        List<TravelProfilePopupDisplay> itemsToRemove = new ArrayList<TravelProfilePopupDisplay>();
        for (TravelProfilePopupDisplay originalProfileDisplay : originalList) {
            
            boolean foundMatch = false;
            for (TravelProfilePopupDisplay tempProfileDisplay : tempTravelProfileDisplays ) {
                if (tempProfileDisplay.getID() == originalProfileDisplay.getID()) {
                    foundMatch=true;
                }
            }
            // If the item only exists in the original list, then remove it
            if (foundMatch==false) {
                // Note: Cannot remove from originalList during iteration
                itemsToRemove.add( originalProfileDisplay );
            }
        }
        originalList.removeAll( itemsToRemove );

Initial URL


Initial Description


Initial Title
Remove from a list during iteration

Initial Tags
list

Initial Language
Java