Exemplo n.º 1
0
 /**
  * Returns the keys for the values in the collection
  *
  * @return The keys (never null)
  * @author Klaus Meffert
  * @since 2.3
  */
 public List getKeys() {
   final List result = new java.util.ArrayList();
   final Iterator iterator = m_data.iterator();
   while (iterator.hasNext()) {
     final KeyedValue kv = (KeyedValue) iterator.next();
     result.add(kv.getKey());
   }
   return result;
 }
Exemplo n.º 2
0
 /**
  * @return clone of the current instance
  * @author Klaus Meffert
  * @since 2.3
  */
 public Object clone() {
   try {
     final KeyedValues clone = (KeyedValues) super.clone();
     clone.m_data = Collections.synchronizedList(new ArrayList());
     final Iterator iterator = m_data.iterator();
     while (iterator.hasNext()) {
       final KeyedValue kv = (KeyedValue) iterator.next();
       clone.m_data.add(kv.clone());
     }
     return clone;
   } catch (CloneNotSupportedException cex) {
     throw new CloneException(cex);
   }
 }
Exemplo n.º 3
0
 /**
  * @param a_key the key to search for
  * @return index for a given key or -1 if the key is not found
  * @author Klaus Meffert
  * @since 2.3
  */
 public int getIndex(final Comparable a_key) {
   int i = 0;
   final Iterator iterator = m_data.iterator();
   while (iterator.hasNext()) {
     final KeyedValue kv = (KeyedValue) iterator.next();
     if (kv.getKey() != null) {
       if (kv.getKey().equals(a_key)) {
         return i;
       }
     } else {
       if (a_key == null) {
         return i;
       }
     }
     i++;
   }
   // key not found
   return -1;
 }