That's awful in terms of efficiency, especially if the collections themselves are not hashed. I cannot imagine what you would use that for...
If all you care about is to know fast if any collection in your map contains an entry, then keep an HashSet of all the collections values (set.addAll(collection)), and query that hashset. Note what you wanted to hear ?!?! ;-) --DD -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, September 16, 2002 11:18 AM To: Ant Developers List Subject: Re: Looking for map with collection values with contains method at map level I messed up the example. It should read: ======================================== //Example FancyMap fm = new FancyMap(); Collection col1 = new ArrayList(); col1.add("jimmy"); col1.add("was"); col1.add("here"); Collection col2 = new ArrayList(); col2.add("gonzo's"); col2.add("big"): col2.add("nose"); fm.put("key1", col1); fm.put("key2", col2); boolean wordFound = fm.anyCollectionContains("jimmy"); ========================================== An implementation I quickly made as an inner class is: private class CollectionMap extends HashMap { public CollectionMap() { super(); } public boolean anyCollectionContains(Object o1) { boolean objectFound = false; Collection values = this.values(); Iterator iter = values.iterator(); while (iter.hasNext()) { Collection value = (Collection) iter.next(); if (value.contains(o1)) { objectFound = true; break; } } return objectFound; } } I was simply hoping to find something as part of a popular library, preferably ant or commons related. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
