ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1628527 - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection: ArrayListMap.java HashSetMap.java ImmutableCollectionMap.java
Date Tue, 30 Sep 2014 19:54:03 GMT
Author: seanfinan
Date: Tue Sep 30 19:54:03 2014
New Revision: 1628527

URL: http://svn.apache.org/r1628527
Log:
ImmutableCollectionMap obtainCollection now returns getCollection
removed commented old code in ArrayListMap and HashSetMap

Modified:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java?rev=1628527&r1=1628526&r2=1628527&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java
Tue Sep 30 19:54:03 2014
@@ -222,179 +222,4 @@ final public class ArrayListMap<K, V> im
       return _delegate;
    }
 
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//   public ArrayListMap() {
-//      super();
-//   }
-//
-//   /**
-//    * @param size initial size of the ArrayListMap
-//    */
-//   public ArrayListMap( final int size ) {
-//      super( size );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Iterator<Map.Entry<K, Collection<V>>> iterator() {
-//      final Iterator<Map.Entry<K, List<V>>> setIterator = entrySet().iterator();
-//      return new Iterator<Map.Entry<K, Collection<V>>>() {
-//         public boolean hasNext() {
-//            return setIterator.hasNext();
-//         }
-//
-//         public Map.Entry<K, Collection<V>> next() {
-//            final Map.Entry<K, List<V>> next = setIterator.next();
-//            return new Map.Entry<K, Collection<V>>() {
-//               public K getKey() {
-//                  return next.getKey();
-//               }
-//
-//               public Collection<V> getValue() {
-//                  return next.getValue();
-//               }
-//
-//               public Collection<V> setValue( final Collection<V> value ) {
-//                  return null;
-//               }
-//            };
-//         }
-//
-//         public void remove() {
-//         }
-//      };
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<Collection<V>> getAllCollections() {
-//      return new HashSet<Collection<V>>( values() );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<V> getCollection( final K key ) {
-//      final List<V> list = get( key );
-//      if ( list != null ) {
-//         return list;
-//      }
-//      return Collections.emptyList();
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<V> obtainCollection( final K key ) {
-//      List<V> list = get( key );
-//      if ( list == null ) {
-//         list = new ArrayList<>();
-//         put( key, list );
-//      }
-//      return list;
-//   }
-//
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean containsValue( final K key, final V value ) {
-//      final Collection<V> values = get( key );
-//      return values != null && values.contains( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean placeValue( final K key, final V value ) {
-//      List<V> list = get( key );
-//      if ( list == null ) {
-//         list = new ArrayList<>();
-//         put( key, list );
-//      }
-//      return list.add( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean placeMap( final Map<K, V> map ) {
-//      boolean placedAny = false;
-//      for ( Map.Entry<K, V> entry : map.entrySet() ) {
-//         final boolean placed = placeValue( entry.getKey(), entry.getValue() );
-//         placedAny = placedAny || placed;
-//      }
-//      return placedAny;
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public void removeValue( final K key, final V value ) {
-//      final List<V> list = get( key );
-//      if ( list == null ) {
-//         return;
-//      }
-//      list.remove( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public int addAllValues( final K key, final Collection<V> collection ) {
-//      List<V> list = get( key );
-//      if ( list == null ) {
-//         list = new ArrayList<>();
-//         put( key, list );
-//      }
-//      final int oldSize = list.size();
-//      list.addAll( collection );
-//      return list.size() - oldSize;
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public void clearCollection( final K key ) {
-//      List<V> list = get( key );
-//      if ( list != null ) {
-//         list.clear();
-//      }
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Map<K, Collection<V>> toSimpleMap() {
-//      final Map<K, Collection<V>> simpleMap = new HashMap<>( size() );
-//      for ( K key : keySet() ) {
-//         simpleMap.put( key, obtainCollection( key ) );
-//      }
-//      return simpleMap;
-//   }
-
 }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java?rev=1628527&r1=1628526&r2=1628527&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java
Tue Sep 30 19:54:03 2014
@@ -222,197 +222,4 @@ final public class HashSetMap<K, V> impl
       return _delegate;
    }
 
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//   public HashSetMap() {
-//      super();
-//   }
-//
-//   /**
-//    * @param size initial size of the HashSetMap
-//    */
-//   public HashSetMap( final int size ) {
-//      super( size );
-//   }
-//
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Iterator<Map.Entry<K, Collection<V>>> iterator() {
-//      final Iterator<Map.Entry<K, Set<V>>> setIterator = entrySet().iterator();
-//      return new Iterator<Map.Entry<K, Collection<V>>>() {
-//         public boolean hasNext() {
-//            return setIterator.hasNext();
-//         }
-//
-//         public Map.Entry<K, Collection<V>> next() {
-//            final Map.Entry<K, Set<V>> next = setIterator.next();
-//            return new Map.Entry<K, Collection<V>>() {
-//               public K getKey() {
-//                  return next.getKey();
-//               }
-//
-//               public Collection<V> getValue() {
-//                  return next.getValue();
-//               }
-//
-//               public Collection<V> setValue( final Collection<V> value ) {
-//                  return null;
-//               }
-//            };
-//         }
-//
-//         public void remove() {
-//         }
-//      };
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<Collection<V>> getAllCollections() {
-//      return new HashSet<Collection<V>>( values() );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<V> getCollection( final K key ) {
-//      final Set<V> set = get( key );
-//      if ( set != null ) {
-//         return set;
-//      }
-//      return Collections.emptySet();
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Collection<V> obtainCollection( final K key ) {
-//      Set<V> set = get( key );
-//      if ( set == null ) {
-//         set = new HashSet<>();
-//         put( key, set );
-//      }
-//      return set;
-//   }
-//
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean containsValue( final K key, final V value ) {
-//      final Collection<V> values = get( key );
-//      return values != null && values.contains( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean placeValue( final K key, final V value ) {
-//      Set<V> set = get( key );
-//      if ( set == null ) {
-//         set = new HashSet<>();
-//         put( key, set );
-//      }
-//      return set.add( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public boolean placeMap( final Map<K, V> map ) {
-//      boolean placedAny = false;
-//      for ( Map.Entry<K, V> entry : map.entrySet() ) {
-//         final boolean placed = placeValue( entry.getKey(), entry.getValue() );
-//         placedAny = placedAny || placed;
-//      }
-//      return placedAny;
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public void removeValue( final K key, final V value ) {
-//      final Set<V> set = get( key );
-//      if ( set == null ) {
-//         return;
-//      }
-//      set.remove( value );
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public int addAllValues( final K key, final Collection<V> collection ) {
-//      Set<V> set = get( key );
-//      if ( set == null ) {
-//         set = new HashSet<>();
-//         put( key, set );
-//      }
-//      final int oldSize = set.size();
-//      set.addAll( collection );
-//      return set.size() - oldSize;
-//   }
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public void clearCollection( final K key ) {
-//      final Set<V> set = get( key );
-//      if ( set != null ) {
-//         set.clear();
-//      }
-//   }
-//
-//
-//   /**
-//    * {@inheritDoc}
-//    */
-//   @Override
-//   public Map<K, Collection<V>> toSimpleMap() {
-//      final Map<K, Collection<V>> simpleMap = new HashMap<>( size() );
-//      for ( K key : keySet() ) {
-//         simpleMap.put( key, obtainCollection( key ) );
-//      }
-//      return simpleMap;
-//   }
-
 }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java?rev=1628527&r1=1628526&r2=1628527&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java
Tue Sep 30 19:54:03 2014
@@ -31,7 +31,7 @@ final public class ImmutableCollectionMa
     */
    @Override
    public Collection<T> getAllCollections() {
-      return new HashSet<>( _protectedMap.values() );
+      return Collections.unmodifiableCollection( _protectedMap.values() );
    }
 
    /**
@@ -39,6 +39,7 @@ final public class ImmutableCollectionMa
     */
    @Override
    public T getCollection( final K key ) {
+      // unfortunately, we cannot use an unmodifiable from Collections
       return _protectedMap.getCollection( key );
    }
 
@@ -47,7 +48,7 @@ final public class ImmutableCollectionMa
     */
    @Override
    public T obtainCollection( final K key ) {
-      return _protectedMap.obtainCollection( key );
+      return getCollection( key );
    }
 
 



Mime
View raw message