litesoft
@ 964
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / common / shared / utils / NoEqualsUniqueCollector.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package com.temp.common.shared.utils; import java.util.*; public class NoEqualsUniqueCollector<E, C extends Comparable<C>> { private final List<E> entries = new ArrayList<E>(); private final Set<C> uniqueKeys = new HashSet<C>(); private final NoEqualsHelper<E, C> helper; public NoEqualsUniqueCollector( NoEqualsHelper<E, C> helper ) { this.helper = helper; } public boolean isEmpty() { return entries.isEmpty(); } public void add( E entry ) { if ( (entry != null) && uniqueKeys.add( helper.getProxyValue( entry ) ) ) { entries.add( entry ); } } public void addAll( Collection<E> entries ) { if ( entries != null ) { for ( E entry : entries ) { add( entry ); } } } public E[] toArray() { return entries.toArray( helper.createArray( entries.size() ) ); } public List<E> toList() { return new ArrayList<E>( entries ); } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/common/shared/utils/NoEqualsUniqueCollector.java
Revision | Author | Commited | Message |
---|---|---|---|
964 | GeorgeS | Fri 01 Aug, 2014 03:18:23 +0000 | ! |