method2testcases
stringlengths
118
6.63k
### Question: ProxyUtils { public static String getJavaClassName(Class<?> clazz) { if (clazz.isArray()) { return getJavaClassName(clazz.getComponentType()) + "[]"; } return clazz.getName(); } private ProxyUtils(); static Class<?>[] getAllInterfaces(Class<?> cls); static String getJavaClassName(Class<?> clazz); static ...
### Question: MethodSignature implements Serializable { @Override public boolean equals(Object o) { if (o == null) { return false; } if (o == this) { return true; } if (o.getClass() != getClass()) { return false; } MethodSignature other = (MethodSignature) o; return other.internal.equals(internal); } MethodSignature(Me...
### Question: MethodSignature implements Serializable { @Override public String toString() { return internal; } MethodSignature(Method method); Method toMethod(Class<?> type); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer: @Test public void testToString() throws...
### Question: MethodSignature implements Serializable { public Method toMethod(Class<?> type) { final Pair<String, Class<?>[]> info = parse(internal); return MethodUtils.getAccessibleMethod(type, info.getLeft(), info.getRight()); } MethodSignature(Method method); Method toMethod(Class<?> type); @Override boolean equals...
### Question: ObjectProviderUtils { public static <T> ObjectProvider<T> bean(Class<T> beanClass) { return new BeanProvider<T>(beanClass); } private ObjectProviderUtils(); static ObjectProvider<T> bean(Class<T> beanClass); static ObjectProvider<T> cloning(T prototype); static ObjectProvider<T> constant(T value); static...
### Question: ObjectProviderUtils { public static <T extends Cloneable> ObjectProvider<T> cloning(T prototype) { return new CloningProvider<T>(prototype); } private ObjectProviderUtils(); static ObjectProvider<T> bean(Class<T> beanClass); static ObjectProvider<T> cloning(T prototype); static ObjectProvider<T> constant...
### Question: ObjectProviderUtils { public static <T> ObjectProvider<T> constant(T value) { return new ConstantProvider<T>(value); } private ObjectProviderUtils(); static ObjectProvider<T> bean(Class<T> beanClass); static ObjectProvider<T> cloning(T prototype); static ObjectProvider<T> constant(T value); static Object...
### Question: ObjectProviderUtils { public static <T> ObjectProvider<T> nullValue() { return new NullProvider<T>(); } private ObjectProviderUtils(); static ObjectProvider<T> bean(Class<T> beanClass); static ObjectProvider<T> cloning(T prototype); static ObjectProvider<T> constant(T value); static ObjectProvider<T> nul...
### Question: ObjectProviderUtils { public static <T> ObjectProvider<T> singleton(ObjectProvider<T> inner) { return new SingletonProvider<T>(inner); } private ObjectProviderUtils(); static ObjectProvider<T> bean(Class<T> beanClass); static ObjectProvider<T> cloning(T prototype); static ObjectProvider<T> constant(T val...
### Question: ConstantProvider implements ObjectProvider<T>, Serializable { @Override public T getObject() { return constant; } ConstantProvider(T constant); @Override T getObject(); }### Answer: @Test public void testGetObject() throws Exception { final String s = "Hello, World!"; final ConstantProvider<String> provi...
### Question: Sh1106 implements Closeable { public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level)...
### Question: Int2IntOpenHashMapWritable extends Int2IntOpenHashMap implements Writable { public void increment(int key) { increment(key, 1); } Int2IntOpenHashMapWritable(); @Override void readFields(DataInput in); void decode(); boolean hasBeenDecoded(); @Override void write(DataOutput out); byte[] serialize(); static...
### Question: ArrayListWritable extends ArrayList<E> implements Writable { public String toString() { StringBuffer sb = new StringBuffer(); sb.append("["); for (int i = 0; i < this.size(); i++) { if (i != 0) sb.append(", "); sb.append(this.get(i)); } sb.append("]"); return sb.toString(); } ArrayListWritable(); ArrayLi...
### Question: HMapII implements MapII, Cloneable, Serializable { @Override public void plus(MapII m) { for (MapII.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } HMapII(int initialCapacity, float loadFa...
### Question: HMapII implements MapII, Cloneable, Serializable { @Override public long dot(MapII m) { int s = 0; for (MapII.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } HMapII(int initialCapacity, float loadFactor); HMapII(int initialCa...
### Question: HMapII implements MapII, Cloneable, Serializable { @Override public void increment(int key) { if (this.containsKey(key)) { this.put(key, this.get(key) + 1); } else { this.put(key, 1); } } HMapII(int initialCapacity, float loadFactor); HMapII(int initialCapacity); HMapII(); HMapII(MapII m); @Override in...
### Question: HMapII implements MapII, Cloneable, Serializable { public MapII.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapII.Entry[] entries = new Entry[this.size()]; int i = 0; Entry next = null; int index = 0; while (index < table.length && (next = table[index++]) == null) ; while (next ...
### Question: HMapII implements MapII, Cloneable, Serializable { @Override public int put(int key, int value) { int hash = hash(key); int i = indexFor(hash, table.length); for (Entry e = table[i]; e != null; e = e.next) { int k; if (e.hash == hash && ((k = e.key) == key || key == k)) { int oldValue = e.value; e.value =...
### Question: HMapILW extends HMapIL implements Writable { @Override public int size() { if (!isDecoded()) { return keys.length; } return super.size(); } HMapILW(); void readFields(DataInput in); void decode(); boolean isDecoded(); void write(DataOutput out); byte[] serialize(); static HMapILW create(DataInput in); sta...
### Question: HMapIFW extends HMapIF implements Writable { @Override public int size() { if (!isDecoded()) { return keys.length; } return super.size(); } HMapIFW(); void readFields(DataInput in); void decode(); boolean isDecoded(); void write(DataOutput out); byte[] serialize(); static HMapIFW create(DataInput in); sta...
### Question: HMapKS implements MapKS<K>, Cloneable, Serializable { @Override public void plus(MapKS<K> m) { for (MapKS.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { this.put(key, (short) (this.get(key) + e.getValue())); } else { this.put(key, e.getValue()); } } } @SuppressWarnings("unch...
### Question: Int2LongOpenHashMapWritable extends Int2LongOpenHashMap implements Writable { public void lazyplus(Int2LongOpenHashMapWritable m) { int[] k = m.getKeys(); long[] v = m.getValues(); for (int i = 0; i < k.length; i++) { if (this.containsKey(k[i])) { this.put(k[i], this.get(k[i]) + v[i]); } else { this.put(k...
### Question: HMapKS implements MapKS<K>, Cloneable, Serializable { @Override public long dot(MapKS<K> m) { int s = 0; for (MapKS.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } @SuppressWarnings("unchecked") HMapKS(int initialCapacity, f...
### Question: HMapKS implements MapKS<K>, Cloneable, Serializable { @Override public void increment(K key) { if (this.containsKey(key)) { this.put(key, (short) (this.get(key) + 1)); } else { this.put(key, (short) 1); } } @SuppressWarnings("unchecked") HMapKS(int initialCapacity, float loadFactor); HMapKS(int initialC...
### Question: HMapIDW extends HMapID implements Writable { @Override public int size() { if (!isDecoded()) { return keys.length; } return super.size(); } HMapIDW(); void readFields(DataInput in); void decode(); boolean isDecoded(); void write(DataOutput out); byte[] serialize(); static HMapIDW create(DataInput in); sta...
### Question: HMapKI implements MapKI<K>, Cloneable, Serializable { @Override public void plus(MapKI<K> m) { for (MapKI.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } @SuppressWarnings("unchecked") H...
### Question: HMapKI implements MapKI<K>, Cloneable, Serializable { @Override public long dot(MapKI<K> m) { int s = 0; for (MapKI.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } @SuppressWarnings("unchecked") HMapKI(int initialCapacity, f...
### Question: HMapKI implements MapKI<K>, Cloneable, Serializable { @Override public void increment(K key) { if (this.containsKey(key)) { this.put(key, this.get(key) + 1); } else { this.put(key, 1); } } @SuppressWarnings("unchecked") HMapKI(int initialCapacity, float loadFactor); HMapKI(int initialCapacity); @Suppres...
### Question: HMapKI implements MapKI<K>, Cloneable, Serializable { @Override public String toString() { Iterator<MapKI.Entry<K>> i = entrySet().iterator(); if (!i.hasNext()) return "{}"; StringBuilder sb = new StringBuilder(); sb.append('{'); for (;;) { MapKI.Entry<K> e = i.next(); K key = e.getKey(); int value = e.ge...
### Question: HMapIV implements MapIV<V>, Cloneable, Serializable { @SuppressWarnings("unchecked") public MapIV.Entry<V>[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapIV.Entry<V>[] entries = new Entry[this.size()]; int i = 0; Entry<V> next = null; int index = 0; while (index < table.length && (nex...
### Question: HMapIIW extends HMapII implements Writable { @Override public int size() { if (!isDecoded()) { return keys.length; } return super.size(); } HMapIIW(); void readFields(DataInput in); void decode(); boolean isDecoded(); void write(DataOutput out); byte[] serialize(); static HMapIIW create(DataInput in); sta...
### Question: HMapIL implements MapIL, Cloneable, Serializable { @Override public void plus(MapIL m) { for (MapIL.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } HMapIL(int initialCapacity, float loadFa...
### Question: Int2LongOpenHashMapWritable extends Int2LongOpenHashMap implements Writable { public long dot(Int2LongOpenHashMapWritable m) { int s = 0; for (Int2LongMap.Entry e : m.int2LongEntrySet()) { int key = e.getIntKey(); if (this.containsKey(key)) { s += this.get(key) * e.getLongValue(); } } return s; } Int2Long...
### Question: HMapIL implements MapIL, Cloneable, Serializable { @Override public long dot(MapIL m) { long s = 0; for (MapIL.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } HMapIL(int initialCapacity, float loadFactor); HMapIL(int initialC...
### Question: HMapIL implements MapIL, Cloneable, Serializable { @Override public void increment(int key) { if (this.containsKey(key)) { this.put(key, (long) (this.get(key) + 1)); } else { this.put(key, (long) 1); } } HMapIL(int initialCapacity, float loadFactor); HMapIL(int initialCapacity); HMapIL(); HMapIL(MapIL ...
### Question: HMapIL implements MapIL, Cloneable, Serializable { public MapIL.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapIL.Entry[] entries = new Entry[this.size()]; int i = 0; Entry next = null; int index = 0; while (index < table.length && (next = table[index++]) == null) ; while (next ...
### Question: HMapKF implements MapKF<K>, Cloneable, Serializable { @Override public void plus(MapKF<K> m) { for (MapKF.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } @SuppressWarnings("unchecked") H...
### Question: HMapKF implements MapKF<K>, Cloneable, Serializable { @Override public double dot(MapKF<K> m) { double s = 0.0f; for (MapKF.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } @SuppressWarnings("unchecked") HMapKF(int initialCap...
### Question: HMapKF implements MapKF<K>, Cloneable, Serializable { @Override public void increment(K key) { if (this.containsKey(key)) { this.put(key, (float) this.get(key) + 1.0f); } else { this.put(key, 1.0f); } } @SuppressWarnings("unchecked") HMapKF(int initialCapacity, float loadFactor); HMapKF(int initialCapac...
### Question: HMapID implements MapID, Cloneable, Serializable { @Override public void plus(MapID m) { for (MapID.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } HMapID(int initialCapacity, float loadFa...
### Question: HMapID implements MapID, Cloneable, Serializable { @Override public double dot(MapID m) { double s = 0.0f; for (MapID.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } HMapID(int initialCapacity, float loadFactor); HMapID(int i...
### Question: HMapID implements MapID, Cloneable, Serializable { @Override public void increment(int key) { if (this.containsKey(key)) { this.put(key, this.get(key) + 1.0); } else { this.put(key, 1.0); } } HMapID(int initialCapacity, float loadFactor); HMapID(int initialCapacity); HMapID(); HMapID(MapID m); int size...
### Question: HMapID implements MapID, Cloneable, Serializable { public MapID.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapID.Entry[] entries = new Entry[this.size()]; int i = 0; Entry next = null; int index = 0; while (index < table.length && (next = table[index++]) == null) ; while (next ...
### Question: Int2LongOpenHashMapWritable extends Int2LongOpenHashMap implements Writable { public Int2LongMap.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; Int2LongMap.Entry[] entries = new Int2LongMap.Entry[this.size()]; entries = this.int2LongEntrySet().toArray(entries); Arrays.sort(entries,...
### Question: HMapIS implements MapIS, Cloneable, Serializable { @Override public void plus(MapIS m) { for (MapIS.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { this.put(key, (short) (this.get(key) + e.getValue())); } else { this.put(key, e.getValue()); } } } HMapIS(int initialCapacity, fl...
### Question: HMapIS implements MapIS, Cloneable, Serializable { @Override public long dot(MapIS m) { int s = 0; for (MapIS.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } HMapIS(int initialCapacity, float loadFactor); HMapIS(int initialCa...
### Question: HMapIS implements MapIS, Cloneable, Serializable { @Override public void increment(int key) { if (this.containsKey(key)) { this.put(key, (short) (this.get(key) + 1)); } else { this.put(key, (short) 1); } } HMapIS(int initialCapacity, float loadFactor); HMapIS(int initialCapacity); HMapIS(); HMapIS(MapI...
### Question: HMapIS implements MapIS, Cloneable, Serializable { public MapIS.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapIS.Entry[] entries = new Entry[this.size()]; int i = 0; Entry next = null; int index = 0; while (index < table.length && (next = table[index++]) == null) ; while (next ...
### Question: HMapKL implements MapKL<K>, Cloneable, Serializable { @Override public void plus(MapKL<K> m) { for (MapKL.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { this.put(key, (long) (this.get(key) + e.getValue())); } else { this.put(key, e.getValue()); } } } @SuppressWarnings("unche...
### Question: HMapKL implements MapKL<K>, Cloneable, Serializable { @Override public long dot(MapKL<K> m) { long s = 0; for (MapKL.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } @SuppressWarnings("unchecked") HMapKL(int initialCapacity, ...
### Question: HMapKL implements MapKL<K>, Cloneable, Serializable { @Override public void increment(K key) { if (this.containsKey(key)) { this.put(key, (long) this.get(key) + 1L); } else { this.put(key, (long) 1L); } } @SuppressWarnings("unchecked") HMapKL(int initialCapacity, float loadFactor); HMapKL(int initialCap...
### Question: HMapIF implements MapIF, Cloneable, Serializable { @Override public void plus(MapIF m) { for (MapIF.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { this.put(key, this.get(key) + e.getValue()); } else { this.put(key, e.getValue()); } } } HMapIF(int initialCapacity, float loadFa...
### Question: HMapIF implements MapIF, Cloneable, Serializable { @Override public double dot(MapIF m) { double s = 0.0f; for (MapIF.Entry e : m.entrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } HMapIF(int initialCapacity, float loadFactor); HMapIF(int i...
### Question: HMapIF implements MapIF, Cloneable, Serializable { @Override public void increment(int key) { if (this.containsKey(key)) { this.put(key, (float) this.get(key) + 1.0f); } else { this.put(key, 1.0f); } } HMapIF(int initialCapacity, float loadFactor); HMapIF(int initialCapacity); HMapIF(); HMapIF(MapIF m)...
### Question: HMapIF implements MapIF, Cloneable, Serializable { public MapIF.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; MapIF.Entry[] entries = new Entry[this.size()]; int i = 0; Entry next = null; int index = 0; while (index < table.length && (next = table[index++]) == null) ; while (next ...
### Question: Int2FloatOpenHashMapWritable extends Int2FloatOpenHashMap implements Writable { public void increment(int key) { increment(key, 1.0f); } Int2FloatOpenHashMapWritable(); @Override void readFields(DataInput in); void decode(); boolean hasBeenDecoded(); @Override void write(DataOutput out); byte[] serialize(...
### Question: Int2FloatOpenHashMapWritable extends Int2FloatOpenHashMap implements Writable { public void plus(Int2FloatOpenHashMapWritable m) { for (Int2FloatMap.Entry e : m.int2FloatEntrySet()) { int key = e.getKey(); float value = e.getValue(); if (this.containsKey(key)) { this.put(key, this.get(key) + value); } els...
### Question: Int2FloatOpenHashMapWritable extends Int2FloatOpenHashMap implements Writable { public void lazyplus(Int2FloatOpenHashMapWritable m) { int[] keys = m.getKeys(); float[] values = m.getValues(); for (int i = 0; i < keys.length; i++) { if (this.containsKey(keys[i])) { this.put(keys[i], this.get(keys[i]) + va...
### Question: Int2FloatOpenHashMapWritable extends Int2FloatOpenHashMap implements Writable { public int dot(Int2FloatOpenHashMapWritable m) { int s = 0; for (Int2FloatMap.Entry e : m.int2FloatEntrySet()) { int key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; } Int2FloatOp...
### Question: Int2IntOpenHashMapWritable extends Int2IntOpenHashMap implements Writable { public void plus(Int2IntOpenHashMapWritable m) { for (Int2IntMap.Entry e : m.int2IntEntrySet()) { int key = e.getIntKey(); int value = e.getIntValue(); if (this.containsKey(key)) { this.put(key, this.get(key) + value); } else { th...
### Question: PairOfStringInt implements WritableComparable<PairOfStringInt> { public boolean equals(Object obj) { PairOfStringInt pair = (PairOfStringInt) obj; return leftElement.equals(pair.getLeftElement()) && rightElement == pair.getRightElement(); } PairOfStringInt(); PairOfStringInt(String left, int right); void...
### Question: PairOfFloatString implements WritableComparable<PairOfFloatString> { @Override public boolean equals(Object obj) { PairOfFloatString pair = (PairOfFloatString) obj; return rightElement.equals(pair.getRightElement()) && leftElement == pair.getLeftElement(); } PairOfFloatString(); PairOfFloatString(float l...
### Question: PairOfStringFloat implements WritableComparable<PairOfStringFloat> { @Override public boolean equals(Object obj) { PairOfStringFloat pair = (PairOfStringFloat) obj; return leftElement.equals(pair.getLeftElement()) && rightElement == pair.getRightElement(); } PairOfStringFloat(); PairOfStringFloat(String ...
### Question: PairOfStringLong implements WritableComparable<PairOfStringLong> { public boolean equals(Object obj) { PairOfStringLong pair = (PairOfStringLong) obj; return leftElement.equals(pair.getLeftElement()) && rightElement == pair.getRightElement(); } PairOfStringLong(); PairOfStringLong(String left, long right...
### Question: PairOfLongString implements WritableComparable<PairOfLongString> { @Override public boolean equals(Object obj) { PairOfLongString pair = (PairOfLongString) obj; return rightElement.equals(pair.getRightElement()) && leftElement == pair.getLeftElement(); } PairOfLongString(); PairOfLongString(long left, St...
### Question: PairOfStrings implements WritableComparable<PairOfStrings> { public boolean equals(Object obj) { PairOfStrings pair = (PairOfStrings) obj; return leftElement.equals(pair.getLeftElement()) && rightElement.equals(pair.getRightElement()); } PairOfStrings(); PairOfStrings(String left, String right); void rea...
### Question: Int2IntOpenHashMapWritable extends Int2IntOpenHashMap implements Writable { public void lazyplus(Int2IntOpenHashMapWritable m) { int[] k = m.getKeys(); int[] v = m.getValues(); for (int i = 0; i < k.length; i++) { if (this.containsKey(k[i])) { this.put(k[i], this.get(k[i]) + v[i]); } else { this.put(k[i],...
### Question: PairOfStrings implements WritableComparable<PairOfStrings> { public int hashCode() { return Objects.hash(leftElement, rightElement); } PairOfStrings(); PairOfStrings(String left, String right); void readFields(DataInput in); void write(DataOutput out); String getLeftElement(); String getRightElement(); S...
### Question: JsonWritable implements Writable { public byte[] serialize() throws IOException { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(bytesOut); write(dataOut); return bytesOut.toByteArray(); } JsonWritable(); JsonWritable(String s); void readFiel...
### Question: ArrayListWritableComparable extends ArrayList<E> implements WritableComparable<ArrayListWritableComparable<E>> { public String toString() { StringBuffer sb = new StringBuffer(); sb.append("["); for (int i = 0; i < this.size(); i++) { if (i != 0) sb.append(", "); sb.append(this.get(i)); } sb.append("]"); r...
### Question: ArrayListWritableComparable extends ArrayList<E> implements WritableComparable<ArrayListWritableComparable<E>> { public int compareTo(ArrayListWritableComparable<E> obj) { ArrayListWritableComparable<E> that = (ArrayListWritableComparable<E>) obj; for (int i = 0; i < this.size(); i++) { if (i >= that.size...
### Question: ArrayListOfLongsWritable extends ArrayListOfLongs implements WritableComparable<ArrayListOfLongsWritable> { @Override public String toString() { return toString(size()); } ArrayListOfLongsWritable(); ArrayListOfLongsWritable(int initialCapacity); ArrayListOfLongsWritable(int first, int last); Array...
### Question: ArrayListOfLongsWritable extends ArrayListOfLongs implements WritableComparable<ArrayListOfLongsWritable> { @Override public int compareTo(ArrayListOfLongsWritable obj) { ArrayListOfLongsWritable other = (ArrayListOfLongsWritable) obj; if (isEmpty()) { if (other.isEmpty()) { return 0; } else { return ...
### Question: Int2IntOpenHashMapWritable extends Int2IntOpenHashMap implements Writable { public long dot(Int2IntOpenHashMapWritable m) { int s = 0; for (Int2IntMap.Entry e : m.int2IntEntrySet()) { int key = e.getIntKey(); if (this.containsKey(key)) { s += this.get(key) * e.getIntValue(); } } return s; } Int2IntOpenHas...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public int size() { return size; } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListOfFloats(int first, int last); void trimToSize(); void ensureCapacity(int minCapacity); int size...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public float remove(int index) { if (index >= size) { throw new ArrayIndexOutOfBoundsException(); } float oldValue = array[index]; int numMoved = size - index - 1; if (numMoved > 0) { System.arraycopy(array, index + 1, array, index, n...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public ArrayListOfFloats clone() { return new ArrayListOfFloats(Arrays.copyOf(array, this.size())); } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListOfFloats(int first, int last)...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public String toString(int n) { StringBuilder s = new StringBuilder(); s.append("["); int sz = size() > n ? n : size; for (int i = 0; i < sz; i++) { s.append(get(i)); if (i < sz - 1) { s.append(", "); } } s.append(size() > n ? String....
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public ArrayListOfFloats add(float e) { ensureCapacity(size + 1); array[size++] = e; return this; } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListOfFloats(int first, int last); ...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public void setSize(int sz) { ensureCapacity(sz); size = sz; } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListOfFloats(int first, int last); void trimToSize(); void ensureCapacit...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public void sort() { trimToSize(); Arrays.sort(getArray()); } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListOfFloats(int first, int last); void trimToSize(); void ensureCapacity...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public ArrayListOfFloats subList(int start, int end) { ArrayListOfFloats sublst = new ArrayListOfFloats(end - start + 1); for (int i = start; i <= end; i++) { sublst.add(get(i)); } return sublst; } ArrayListOfFloats(int initialCapacit...
### Question: ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public void addUnique(int[] arr) { for (int i = 0; i < arr.length; i++) { int elt = arr[i]; if (!contains(elt)) { add(elt); } } } ArrayListOfFloats(int initialCapacity); ArrayListOfFloats(); ArrayListOfFloats(float[] a); ArrayListO...
### Question: Int2IntOpenHashMapWritable extends Int2IntOpenHashMap implements Writable { public Int2IntMap.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; Int2IntMap.Entry[] entries = new Int2IntMap.Entry[this.size()]; entries = this.int2IntEntrySet().toArray(entries); Arrays.sort(entries, new C...
### Question: ArrayListOfIntsWritable extends ArrayListOfInts implements WritableComparable<ArrayListOfIntsWritable> { @Override public String toString() { return toString(size()); } ArrayListOfIntsWritable(); ArrayListOfIntsWritable(int initialCapacity); ArrayListOfIntsWritable(int first, int last); ArrayListOf...
### Question: ArrayListOfIntsWritable extends ArrayListOfInts implements WritableComparable<ArrayListOfIntsWritable> { @Override public int compareTo(ArrayListOfIntsWritable obj) { ArrayListOfIntsWritable other = (ArrayListOfIntsWritable) obj; if (isEmpty()) { if (other.isEmpty()) { return 0; } else { return -1; } ...
### Question: ArrayListOfDoublesWritable extends ArrayListOfDoubles implements WritableComparable<ArrayListOfDoublesWritable> { @Override public int compareTo(ArrayListOfDoublesWritable obj) { ArrayListOfDoublesWritable other = (ArrayListOfDoublesWritable) obj; if (isEmpty()) { if (other.isEmpty()) { return 0; } el...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public int size() { return size; } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(int first, int last); void trimToSize(); void ensureCapacity(int minCapacity); int size(); void s...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public int remove(int index) { if (index >= size) { throw new ArrayIndexOutOfBoundsException(); } int oldValue = array[index]; int numMoved = size - index - 1; if (numMoved > 0) { System.arraycopy(array, index + 1, array, index, numMo...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public ArrayListOfInts clone() { return new ArrayListOfInts(Arrays.copyOf(array, this.size())); } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(int first, int last); void trimToS...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public String toString(int n) { StringBuilder s = new StringBuilder(); s.append("["); int sz = size() > n ? n : size; for (int i = 0; i < sz; i++) { s.append(get(i)); if (i < sz - 1) { s.append(", "); } } s.append(size() > n ? String....
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public ArrayListOfInts add(int e) { ensureCapacity(size + 1); array[size++] = e; return this; } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(int first, int last); void trimToSiz...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public void setSize(int sz) { ensureCapacity(sz); size = sz; } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(int first, int last); void trimToSize(); void ensureCapacity(int minC...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public void sort() { trimToSize(); Arrays.sort(getArray()); } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(int first, int last); void trimToSize(); void ensureCapacity(int minCa...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public ArrayListOfInts subList(int start, int end) { ArrayListOfInts sublst = new ArrayListOfInts(end - start + 1); for (int i = start; i <= end; i++) { sublst.add(get(i)); } return sublst; } ArrayListOfInts(int initialCapacity); Arr...
### Question: ArrayListOfInts implements RandomAccess, Cloneable, Iterable<Integer> { public void addUnique(int[] arr) { for (int i = 0; i < arr.length; i++) { int elt = arr[i]; if (!contains(elt)) { add(elt); } } } ArrayListOfInts(int initialCapacity); ArrayListOfInts(); ArrayListOfInts(int[] a); ArrayListOfInts(in...
### Question: ArrayListOfDoubles implements RandomAccess, Cloneable, Iterable<Double> { public int size() { return size; } ArrayListOfDoubles(int initialCapacity); ArrayListOfDoubles(); ArrayListOfDoubles(double[] a); ArrayListOfDoubles(int first, int last); void trimToSize(); void ensureCapacity(int minCapacity); i...
### Question: ArrayListOfDoubles implements RandomAccess, Cloneable, Iterable<Double> { public double remove(int index) { if (index >= size) { throw new ArrayIndexOutOfBoundsException(); } double oldValue = array[index]; int numMoved = size - index - 1; if (numMoved > 0) { System.arraycopy(array, index + 1, array, inde...
### Question: ArrayListOfDoubles implements RandomAccess, Cloneable, Iterable<Double> { public ArrayListOfDoubles clone() { return new ArrayListOfDoubles(Arrays.copyOf(array, this.size())); } ArrayListOfDoubles(int initialCapacity); ArrayListOfDoubles(); ArrayListOfDoubles(double[] a); ArrayListOfDoubles(int first, ...
### Question: ArrayListOfDoubles implements RandomAccess, Cloneable, Iterable<Double> { public String toString(int n) { StringBuilder s = new StringBuilder(); s.append("["); int sz = size() > n ? n : size; for (int i = 0; i < sz; i++) { s.append(get(i)); if (i < sz - 1) { s.append(", "); } } s.append(size() > n ? Strin...