package structures; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Random; import shared.Shared; import shared.Timer; /** * Extends IntHashSet to track new numbers added for rapid clearing. * This is synchronized with clear, but not remove. * @author Brian Bushnell * @date September 13, 2017 * */ public class IntHashSetList extends IntHashSet{ public static void main(String[] args){ Random randy2=Shared.threadLocalRandom(); IntHashSetList set=new IntHashSetList(20, 0.7f); HashSet set2=new HashSet(20, 0.7f); ArrayList list=new ArrayList(); ArrayList list2=new ArrayList(); for(int i=0; i<1000; i++){ assert(!set.contains(i)); assert(!set2.contains(i)); list.add(Integer.valueOf(i)); } for(int i=0; i<1000; i++){ int r=randy2.nextInt(); list2.add(r); } for(int x : list){ set.add(x); set2.add(x); assert(set.contains(x)); assert(set2.contains(x)); } for(int x : list){ assert(set.contains(x)); assert(set2.contains(x)); set.remove(x); set2.remove(x); assert(!set.contains(x)); assert(!set2.contains(x)); } assert(set.isEmpty()); assert(set2.isEmpty()); for(int x : list2){ set.add(x); set2.add(x); assert(set.contains(x)); assert(set2.contains(x)); } for(int x : list2){ assert(set.contains(x)); assert(set2.contains(x)); set.remove(x); set2.remove(x); assert(!set.contains(x)); assert(!set2.contains(x)); } assert(set.isEmpty()); assert(set2.isEmpty()); int count=4000000; int runs=32; IntList ll=new IntList(count); for(int i=0; i0.25*sizeLimit()){ super.clear(); }else{ for(int i=0; i