Changeset 574 for trunk

Show
Ignore:
Timestamp:
06/02/10 03:21:37 (3 months ago)
Author:
soergel
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/main/java/com/davidsoergel/dsutils/collections/Dereplicator.java

    r571 r574  
    55 
    66/** 
    7  * Save memory by storing only one object for each set of equal() objects.  This is sensible only if the objects are immutable and equals() is legitimate. 
     7 * Save memory by storing only one object for each set of equal() objects.  This is sensible only if the objects are 
     8 * immutable and equals() is legitimate. 
    89 * 
    910 * @author <a href="mailto:dev@davidsoergel.com">David Soergel</a> 
     
    1213public class Dereplicator<T> 
    1314        { 
    14         private Map<T,T> objects = new HashMap<T,T>(); 
     15        private Map<T, T> objects = new HashMap<T, T>(); 
    1516 
    1617        public T derep(T o) 
    1718                { 
     19                if (o == null) 
     20                        { 
     21                        return null; 
     22                        } 
    1823                T result = objects.get(o); 
    19                 if(result == null) 
     24                if (result == null) 
    2025                        { 
    21                         objects.put(o,o); 
     26                        objects.put(o, o); 
    2227                        result = o; 
    2328                        }