public BooleanSet asSet() { BooleanSet set = new BooleanOpenHashSet(3); BooleanColumn unique = unique(); for (int i = 0; i < unique.size(); i++) { set.add((boolean) unique.get(i)); } return set; }
public static boolean in(boolean booleanValue, BooleanOpenHashSet set) { return set.contains(booleanValue); }
@Override public boolean addAll(Collection<? extends Boolean> c) { // The resulting collection will be at least c.size() big if (f <= .5) ensureCapacity(c.size()); // The resulting collection will be sized for c.size() elements else tryCapacity(size() + c.size()); // The resulting collection will be tentatively sized for size() + c.size() // elements return super.addAll(c); } @Override
/** * Creates a new hash set copying a given collection. * * @param c * a {@link Collection} to be copied into the new hash set. * @param f * the load factor. */ public BooleanOpenHashSet(final Collection<? extends Boolean> c, final float f) { this(c.size(), f); addAll(c); } /**
/** * Creates a new hash set and fills it with the elements of a given array. * * @param a * an array whose elements will be used to fill the set. * @param offset * the first element to use. * @param length * the number of elements to use. * @param f * the load factor. */ public BooleanOpenHashSet(final boolean[] a, final int offset, final int length, final float f) { this(length < 0 ? 0 : length, f); BooleanArrays.ensureOffsetLength(a, offset, length); for (int i = 0; i < length; i++) add(a[offset + i]); } /**
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { final BooleanIterator i = iterator(); s.defaultWriteObject(); for (int j = size; j-- != 0;) s.writeBoolean(i.nextBoolean()); }
@Override public boolean addAll(BooleanCollection c) { if (f <= .5) ensureCapacity(c.size()); // The resulting collection will be sized for c.size() elements else tryCapacity(size() + c.size()); // The resulting collection will be tentatively sized for size() + c.size() // elements return super.addAll(c); } @Override
/** * Creates a new hash set copying a given type-specific collection. * * @param c * a type-specific collection to be copied into the new hash set. * @param f * the load factor. */ public BooleanOpenHashSet(final BooleanCollection c, final float f) { this(c.size(), f); addAll(c); } /**
/** * Creates a new hash set using elements provided by a type-specific iterator. * * @param i * a type-specific iterator whose elements will fill the set. * @param f * the load factor. */ public BooleanOpenHashSet(final BooleanIterator i, final float f) { this(DEFAULT_INITIAL_SIZE, f); while (i.hasNext()) add(i.nextBoolean()); } /**
@SuppressWarnings("unchecked") public static Set<?> toFastutilHashSet(Set<?> set, Type type, FunctionRegistry registry) { // 0.25 as the load factor is chosen because the argument set is assumed to be small (<10000), // and the return set is assumed to be read-heavy. // The performance of InCodeGenerator heavily depends on the load factor being small. Class<?> javaElementType = type.getJavaType(); if (javaElementType == long.class) { return new LongOpenCustomHashSet((Collection<Long>) set, 0.25f, new LongStrategy(registry, type)); } if (javaElementType == double.class) { return new DoubleOpenCustomHashSet((Collection<Double>) set, 0.25f, new DoubleStrategy(registry, type)); } if (javaElementType == boolean.class) { return new BooleanOpenHashSet((Collection<Boolean>) set, 0.25f); } else if (!type.getJavaType().isPrimitive()) { return new ObjectOpenCustomHashSet(set, 0.25f, new ObjectStrategy(registry, type)); } else { throw new UnsupportedOperationException("Unsupported native type in set: " + type.getJavaType() + " with type " + type.getTypeSignature()); } }
public static boolean in(boolean booleanValue, BooleanOpenHashSet set) { return set.contains(booleanValue); }
return new LongOpenHashSet(set); } else if (oCls.equals(Boolean.class)) { return new BooleanOpenHashSet(set); } else if (oCls.equals(Character.class)) { return new CharOpenHashSet(set);
public static boolean in(boolean booleanValue, BooleanOpenHashSet set) { return set.contains(booleanValue); }
return new LongOpenHashSet(set); } else if (oCls.equals(Boolean.class)) { return new BooleanOpenHashSet(set); } else if (oCls.equals(Character.class)) { return new CharOpenHashSet(set);
public static boolean in(boolean booleanValue, BooleanOpenHashSet set) { return set.contains(booleanValue); }
public BooleanSet asSet() { BooleanSet set = new BooleanOpenHashSet(3); BooleanColumn unique = unique(); for (int i = 0; i < unique.size(); i++) { set.add((boolean) unique.get(i)); } return set; }
public BooleanSet asSet() { BooleanSet set = new BooleanOpenHashSet(3); BooleanColumn unique = unique(); for (int i = 0; i < unique.size(); i++) { set.add(unique.get(i)); } return set; }
private Set deserializeSet(final DataInput is) throws IOException, ClassNotFoundException { Object h = deserialize(is); Class oCls = h.getClass(); if (oCls.equals(Integer.class)) { int size = (Integer) h; ObjectOpenHashSet set = new ObjectOpenHashSet(size); for (int i = 0; i < size; i++) { set.add(deserialize(is)); } return set; } else if (oCls.equals(int[].class)) { return new IntOpenHashSet((int[]) h); } else if (oCls.equals(float[].class)) { return new FloatOpenHashSet((float[]) h); } else if (oCls.equals(double[].class)) { return new DoubleOpenHashSet((double[]) h); } else if (oCls.equals(short[].class)) { return new ShortOpenHashSet((short[]) h); } else if (oCls.equals(byte[].class)) { return new ByteOpenHashSet((byte[]) h); } else if (oCls.equals(long[].class)) { return new LongOpenHashSet((long[]) h); } else if (oCls.equals(boolean[].class)) { return new BooleanOpenHashSet((boolean[]) h); } else if (oCls.equals(char[].class)) { return new CharOpenHashSet((char[]) h); } throw new EOFException(); }
private Set deserializeSet(final DataInput is) throws IOException, ClassNotFoundException { Object h = deserialize(is); Class oCls = h.getClass(); if (oCls.equals(Integer.class)) { int size = (Integer) h; ObjectOpenHashSet set = new ObjectOpenHashSet(size); for (int i = 0; i < size; i++) { set.add(deserialize(is)); } return set; } else if (oCls.equals(int[].class)) { return new IntOpenHashSet((int[]) h); } else if (oCls.equals(float[].class)) { return new FloatOpenHashSet((float[]) h); } else if (oCls.equals(double[].class)) { return new DoubleOpenHashSet((double[]) h); } else if (oCls.equals(short[].class)) { return new ShortOpenHashSet((short[]) h); } else if (oCls.equals(byte[].class)) { return new ByteOpenHashSet((byte[]) h); } else if (oCls.equals(long[].class)) { return new LongOpenHashSet((long[]) h); } else if (oCls.equals(boolean[].class)) { return new BooleanOpenHashSet((boolean[]) h); } else if (oCls.equals(char[].class)) { return new CharOpenHashSet((char[]) h); } throw new EOFException(); }
@SuppressWarnings({"unchecked"}) public static Set<?> toFastutilHashSet(Set<?> set, Type type, FunctionRegistry registry) { // 0.25 as the load factor is chosen because the argument set is assumed to be small (<10000), // and the return set is assumed to be read-heavy. // The performance of InCodeGenerator heavily depends on the load factor being small. Class<?> javaElementType = type.getJavaType(); if (javaElementType == long.class) { return new LongOpenCustomHashSet((Collection<Long>) set, 0.25f, new LongStrategy(registry, type)); } if (javaElementType == double.class) { return new DoubleOpenCustomHashSet((Collection<Double>) set, 0.25f, new DoubleStrategy(registry, type)); } if (javaElementType == boolean.class) { return new BooleanOpenHashSet((Collection<Boolean>) set, 0.25f); } else if (!type.getJavaType().isPrimitive()) { return new ObjectOpenCustomHashSet(set, 0.25f, new ObjectStrategy(registry, type)); } else { throw new UnsupportedOperationException("Unsupported native type in set: " + type.getJavaType() + " with type " + type.getTypeSignature()); } }