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.

James Lee Carpenter
Software Engineer
Household Technical Services
6602 Convoy Court
San Diego, CA 92111

ph: 858-609-2461
email: [EMAIL PROTECTED]


                                                                                
                                                  
                                                                                
                                                  
                           [EMAIL PROTECTED]       To:     "Ant Developers 
List" <[EMAIL PROTECTED]>                 
                           .com                        cc:                      
                                                  
                                                       Subject:       Looking 
for map with collection values with contains method 
                           09/13/2002 03:14 PM                 at map level     
                                                  
                           Please respond to                                    
                                                  
                           "Ant Developers List"                                
                                                  
                                                                                
                                                  
                                                                                
                                                  




I am looking for a Map implementation that assumes its values are
Collection objects.

The only extra functionality I am looking for above and beyond the Map
interface is for the Map to have a contains method that returns a boolean
indicating whether any of the collections within the map contains the
argument of the contains method.

========================================
//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.add(col1);
fm.add(col2);

boolean wordFound = fm.contains("jimmy");
==========================================

James Lee Carpenter
Software Engineer
Household Technical Services
6602 Convoy Court
San Diego, CA 92111

ph: 858-609-2461
email: [EMAIL PROTECTED]



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to