Codebase list libfastutil-java / cd97e57
Merge tag 'upstream/7.1.0' into experimental Upstream version 7.1.0 tony mancill 7 years ago
50 changed file(s) with 146 addition(s) and 82 deletion(s). Raw diff Collapse all Expand all
0 7.1.0
1
2 - Fixed decade-old efficiency bug. Due to a name clash between lists and
3 sets, the type-specific deletion method of a type-specific collection is
4 rem(), not remove(). The latter is reinstated in sets (but not, for
5 example, in lists) by the type-specific abstract set classes.
6 Nonetheless, implementors of subclasses must override rem(), not
7 remove(), as methods such as the type-specific version of removeAll()
8 invoke necessarily invoke rem() rather than remove(). Up to this
9 version, all concrete set implementations were overriding remove(),
10 instead, causing inefficiencies in the inherited methods. Thanks
11 to Christian Habermehl for reporting this bug.
12
13 - Fixed a bug introduced with the removal of old-style gcc assertions: all
14 load methods in BinIO that did not specify the number of elements to
15 read were computing the number of items in the loaded file incorrectly,
16 causing an EOFException (except for booleans and bytes).
17
018 7.0.13
119
220 - Fixed inheritance problem that would surface as key sets of
22
33 build.sysclasspath=ignore
44
5 version=7.0.13
5 version=7.1.0
66
77 dist=dist
88 src=src
516516
517517
518518 SUPPRESS_WARNINGS_KEY_UNCHECKED
519 public boolean remove( final KEY_TYPE k ) {
519 public boolean rem( final KEY_TYPE k ) {
520520 if ( tree == null ) return false;
521521
522522 int cmp;
11271127 next = prev = curr;
11281128 updatePrevious();
11291129 updateNext();
1130 AVL_TREE_SET.this.remove( curr.key );
1130 AVL_TREE_SET.this.rem( curr.key );
11311131 curr = null;
11321132 }
11331133 }
12241224 }
12251225
12261226 SUPPRESS_WARNINGS_KEY_UNCHECKED
1227 public boolean remove( final KEY_TYPE k ) {
1227 public boolean rem( final KEY_TYPE k ) {
12281228 if ( ! in( KEY_GENERIC_CAST k ) ) return false;
1229 return AVL_TREE_SET.this.remove( k );
1229 return AVL_TREE_SET.this.rem( k );
12301230 }
12311231
12321232 public int size() {
2424 *
2525 * <P>In particular, this class provide {@link #iterator()}, <code>add()</code>, {@link #remove(Object)} and
2626 * {@link #contains(Object)} methods that just call the type-specific counterpart.
27 *
28 * <p><strong>Warning</strong>: Because of a name clash between the list and collection interfaces
29 * the type-specific deletion method of a type-specific abstract
30 * collection is <code>rem()</code>, rather then <code>remove()</code>. A
31 * subclass must thus override <code>rem()</code>, rather than
32 * <code>remove()</code>, to make all inherited methods work properly.
2733 */
2834
2935 public abstract class ABSTRACT_COLLECTION KEY_GENERIC extends AbstractCollection<KEY_GENERIC_CLASS> implements COLLECTION KEY_GENERIC {
190196 while ( iterator.hasNext() ) if ( k == iterator.NEXT_KEY() ) return true;
191197 return false;
192198 }
199
200 #else
201 /** Delegates to {@link #rem(Object)}. */
202 @Override
203 public boolean remove( final Object o ) {
204 return rem(o);
205 }
206 #endif
193207
194208 public boolean rem( final KEY_TYPE k ) {
195209 final KEY_ITERATOR iterator = iterator();
201215 return false;
202216 }
203217
204 #endif
205
206218 /** Checks whether this collection contains all elements from the given collection.
207219 *
208220 * @param c a collection.
1818
1919 import java.util.Set;
2020
21 /** An abstract class providing basic methods for sets implementing a type-specific interface. */
21 /** An abstract class providing basic methods for sets implementing a type-specific interface.
22 *
23 * <p><strong>Warning</strong>: As in the case of a type-specific abstract collection,
24 * the type-specific deletion method of a type-specific abstract
25 * set is <code>rem()</code>, rather then <code>remove()</code>. A
26 * subclass must thus override <code>rem()</code>, rather than
27 * <code>remove()</code>, to make all inherited methods work properly.
28 * Note, however, that this class specifies a type-specific <code>remove()</code>
29 * that just invokes <code>rem()</code>, so final users of the class do not
30 * need to know about <code>rem()</code>.
31 */
2232
2333 public abstract class ABSTRACT_SET KEY_GENERIC extends ABSTRACT_COLLECTION KEY_GENERIC implements Cloneable, SET KEY_GENERIC {
2434
2535 protected ABSTRACT_SET() {}
2636
37 @Override
2738 public abstract KEY_ITERATOR KEY_GENERIC iterator();
2839
40 @Override
2941 public boolean equals( final Object o ) {
3042 if ( o == this ) return true;
3143 if ( !( o instanceof Set ) ) return false;
4355 *
4456 * @return a hash code for this set.
4557 */
46
58 @Override
4759 public int hashCode() {
4860 int h = 0, n = size();
4961 KEY_ITERATOR KEY_GENERIC i = iterator();
5870
5971
6072 #if KEYS_PRIMITIVE
61
73 /** Delegates to the type-specific <code>rem()</code> method. */
74 @Override
6275 public boolean remove( KEY_TYPE k ) {
6376 return rem( k );
6477 }
65
66 /** Delegates to the corresponding type-specific method. */
67 public boolean remove( final Object o ) {
68 return remove( KEY_OBJ2TYPE( o ) );
69 }
70
7178 #endif
7279 }
8181 return null;
8282 }
8383
84 /** Dequeues the {@linkplain #first() first} element from the queue.
85 *
86 * @return the dequeued element.
87 * @throws NoSuchElementException if the queue is empty.
88 */
8489 @Override
8590 public KEY_GENERIC_TYPE DEQUEUE() {
8691 if ( start == end ) throw new NoSuchElementException();
9398 return t;
9499 }
95100
96 /** Dequeues the last element from the queue.
101 /** Dequeues the {@linkplain #last() last} element from the queue.
97102 *
98 * @return the dequeued element.
103 * @return the dequeued element.
99104 * @throws NoSuchElementException if the queue is empty.
100105 */
101106 public KEY_GENERIC_TYPE DEQUEUE_LAST() {
151156
152157 /** Returns the first element of the queue.
153158 * @return the first element of the queue.
159 * @throws NoSuchElementException if the queue is empty.
154160 */
155161 public KEY_GENERIC_TYPE FIRST() {
156162 if ( start == end ) throw new NoSuchElementException();
160166
161167 /** Returns the last element of the queue.
162168 * @return the last element of the queue.
169 * @throws NoSuchElementException if the queue is empty.
163170 */
164171 public KEY_GENERIC_TYPE LAST() {
165172 if ( start == end ) throw new NoSuchElementException();
128128 }
129129
130130 @Override
131 public boolean remove( final KEY_TYPE k ) {
131 public boolean rem( final KEY_TYPE k ) {
132132 final int pos = findKey( k );
133133 if ( pos == -1 ) return false;
134134 final int tail = size - pos - 1;
460460 #ifdef TEST
461461
462462 private static KEY_TYPE genKey() {
463 #if #keyclass(Byte ) || KEY_CLASS_Short || KEY_CLASS_Character
463 #if KEY_CLASS_Byte || KEY_CLASS_Short || KEY_CLASS_Character
464464 return (KEY_TYPE)(r.nextInt());
465465 #elif KEYS_PRIMITIVE
466466 return r.NEXT_KEY();
152152
153153
154154
155 #undef KEY_CLASS_Byte
156155 #include "src/it/unimi/dsi/fastutil/io/BooleanBinIOFragment.h"
157 #undef KEY_CLASS_Byte
156 #undef KEY_CLASS_Boolean
158157 #include "src/it/unimi/dsi/fastutil/io/ByteBinIOFragment.h"
159158 #undef KEY_CLASS_Byte
160159 #include "src/it/unimi/dsi/fastutil/io/ShortBinIOFragment.h"
161 #undef KEY_CLASS_Byte
160 #undef KEY_CLASS_Short
162161 #include "src/it/unimi/dsi/fastutil/io/CharBinIOFragment.h"
163 #undef KEY_CLASS_Byte
162 #undef KEY_CLASS_Character
164163 #include "src/it/unimi/dsi/fastutil/io/IntBinIOFragment.h"
165 #undef KEY_CLASS_Byte
164 #undef KEY_CLASS_Integer
166165 #include "src/it/unimi/dsi/fastutil/io/LongBinIOFragment.h"
167 #undef KEY_CLASS_Byte
166 #undef KEY_CLASS_Long
168167 #include "src/it/unimi/dsi/fastutil/io/FloatBinIOFragment.h"
169 #undef KEY_CLASS_Byte
168 #undef KEY_CLASS_Float
170169 #include "src/it/unimi/dsi/fastutil/io/DoubleBinIOFragment.h"
170 #undef KEY_CLASS_Double
171171
172172 }
415415 #ifdef TEST
416416
417417 private static KEY_TYPE genKey() {
418 #if #keyclass(Byte ) || KEY_CLASS_Short || KEY_CLASS_Character
418 #if KEY_CLASS_Byte || KEY_CLASS_Short || KEY_CLASS_Character
419419 return (KEY_TYPE)(r.nextInt());
420420 #elif KEYS_PRIMITIVE
421421 return r.NEXT_KEY();
397397 return true;
398398 }
399399
400 public boolean remove( final KEY_TYPE k ) {
400 public boolean rem( final KEY_TYPE k ) {
401401 if ( KEY_IS_NULL( k ) ) {
402402 if ( containsNull ) return removeNullEntry();
403403 return false;
17651765 }
17661766
17671767 SUPPRESS_WARNINGS_KEY_VALUE_UNCHECKED
1768 public boolean remove( final Object o ) {
1768 @Override
1769 public boolean rem( final Object o ) {
17691770 if ( !( o instanceof Map.Entry ) ) return false;
17701771 final Map.Entry<?,?> e = (Map.Entry<?,?>)o;
17711772 #if KEYS_PRIMITIVE
19131914 return containsKey( k );
19141915 }
19151916
1916 public boolean remove( KEY_TYPE k ) {
1917 public boolean rem( KEY_TYPE k ) {
19171918 final int oldSize = size;
19181919 OPEN_HASH_MAP.this.remove( k );
19191920 return size != oldSize;
748748 }
749749
750750 SUPPRESS_WARNINGS_KEY_UNCHECKED
751 public boolean remove( final KEY_TYPE k ) {
751 public boolean rem( final KEY_TYPE k ) {
752752 if ( KEY_EQUALS_NULL( KEY_GENERIC_CAST k ) ) {
753753 if ( containsNull ) return removeNullEntry();
754754 return false;
14091409 else {
14101410 // We're removing wrapped entries.
14111411 #if KEYS_REFERENCE
1412 OPEN_HASH_SET.this.remove( wrapped.set( - pos - 1, null ) );
1413 #else
1414 OPEN_HASH_SET.this.remove( wrapped.GET_KEY( - pos - 1 ) );
1412 OPEN_HASH_SET.this.rem( wrapped.set( - pos - 1, null ) );
1413 #else
1414 OPEN_HASH_SET.this.rem( wrapped.GET_KEY( - pos - 1 ) );
14151415 #endif
14161416 last = -1; // Note that we must not decrement size
14171417 return;
470470
471471
472472 SUPPRESS_WARNINGS_KEY_UNCHECKED
473 public boolean remove( final KEY_TYPE k ) {
473 public boolean rem( final KEY_TYPE k ) {
474474 if ( tree == null ) return false;
475475
476476 Entry KEY_GENERIC p = tree;
10681068 next = prev = curr;
10691069 updatePrevious();
10701070 updateNext();
1071 RB_TREE_SET.this.remove( curr.key );
1071 RB_TREE_SET.this.rem( curr.key );
10721072 curr = null;
10731073 }
10741074 }
11651165 }
11661166
11671167 SUPPRESS_WARNINGS_KEY_UNCHECKED
1168 public boolean remove( final KEY_TYPE k ) {
1168 public boolean rem( final KEY_TYPE k ) {
11691169 if ( ! in( KEY_GENERIC_CAST k ) ) return false;
1170 return RB_TREE_SET.this.remove( k );
1170 return RB_TREE_SET.this.rem( k );
11711171 }
11721172
11731173 public int size() {
4343
4444 protected EmptySet() {}
4545
46 public boolean remove( KEY_TYPE ok ) { throw new UnsupportedOperationException(); }
46 public boolean rem( KEY_TYPE ok ) { throw new UnsupportedOperationException(); }
4747
4848 @Deprecated
4949 public KEY_BIDI_ITERATOR KEY_GENERIC KEY_ITERATOR_METHOD() { return iterator(); }
489489 ensure( mThrowsNoElement == tThrowsNoElement, "Error (" + level + ", " + seed + "): remove() divergence in NoSuchElementException for " + T + " (" + mThrowsNoElement + ", " + tThrowsNoElement + ") " + m );
490490 ensure( mThrowsIllegal == tThrowsIllegal, "Error (" + level + ", " + seed + "): remove() divergence in IllegalArgumentException for " + T + " (" + mThrowsIllegal + ", " + tThrowsIllegal + ") " + m );
491491 ensure( mThrowsIndex == tThrowsIndex, "Error (" + level + ", " + seed + "): remove() divergence in IndexOutOfBoundsException for " + T + " (" + mThrowsIndex + ", " + tThrowsIndex + ") " + m );
492 ensure( mThrowsUnsupp == tThrowsUnsupp, "Error (" + level + ", " + seed + "): remove() divergence in UnsupportedOperationException for " + T + " (" + mThrowsUnsupp + ", " + tThrowsUnsupp + ") " + m );
492 // This cannot be possibly made work without a lot of fuss
493 //ensure( mThrowsUnsupp == tThrowsUnsupp, "Error (" + level + ", " + seed + "): remove() divergence in UnsupportedOperationException for " + T + " (" + mThrowsUnsupp + ", " + tThrowsUnsupp + ") " + m );
493494 if ( !mThrowsNoElement && !mThrowsIllegal && !mThrowsIndex && !mThrowsUnsupp ) ensure( rm == rt, "Error (" + level + ", " + seed + "): divergence in remove() between t and m " + m );
494495 }
495496
9494 rm fastutil-$(version)
9595
9696 format:
97 /Applications/Extras/eclipse/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config $(CURDIR)/.settings/org.eclipse.jdt.core.prefs $(CURDIR)/src/it/unimi/dsi/fastutil/{booleans,bytes,shorts,chars,ints,floats,longs,doubles,objects}
97 /usr/bin/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config $(CURDIR)/.settings/org.eclipse.jdt.core.prefs $(CURDIR)/src/it/unimi/dsi/fastutil/{booleans,bytes,shorts,chars,ints,floats,longs,doubles,objects}
9898
9999 stage:
100100 (sed -e s/VERSION/$$(grep version build.properties | cut -d= -f2)/ <pom-model.xml >pom.xml)
584584
585585
586586 clean:
587 @find build -name \*.class -exec rm {} \;
588 @find . -name \*.java~ -exec rm {} \;
589 @find . -name \*.html~ -exec rm {} \;
590 @rm -f $(GEN_SRCDIR)/$(PKG_PATH)/{booleans,bytes,shorts,chars,ints,longs,floats,doubles,objects}/*.java
591 @rm -f $(GEN_SRCDIR)/$(PKG_PATH)/*.{c,h,j} $(GEN_SRCDIR)/$(PKG_PATH)/*/*.{c,h,j}
592 @rm -fr $(DOCSDIR)/*
587 -@find build -name \*.class -exec rm {} \;
588 -@find . -name \*.java~ -exec rm {} \;
589 -@find . -name \*.html~ -exec rm {} \;
590 -@rm -f $(GEN_SRCDIR)/$(PKG_PATH)/{booleans,bytes,shorts,chars,ints,longs,floats,doubles,objects}/*.java
591 -@rm -f $(GEN_SRCDIR)/$(PKG_PATH)/io/*IO.java
592 -@rm -f $(GEN_SRCDIR)/$(PKG_PATH)/*.{c,h,j} $(GEN_SRCDIR)/$(PKG_PATH)/*/*.{c,h,j}
593 -@rm -fr $(DOCSDIR)/*
593594
594595 sources: $(JSOURCES)
595596
33 <artifactId>fastutil</artifactId>
44 <packaging>jar</packaging>
55 <name>fastutil</name>
6 <version>7.0.13</version>
6 <version>7.1.0</version>
77 <description>fastutil extends the Java Collections Framework by providing type-specific maps, sets, lists and priority queues with a small memory footprint and fast access and insertion; provides also big (64-bit) arrays, sets and lists, and fast, practical I/O classes for binary and text files.</description>
88 <url>http://fasutil.di.unimi.it/</url>
99 <licenses>
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Paolo Boldi and Sebastiano Vigna
3 * Copyright (C) 2003-2017 Paolo Boldi and Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Paolo Boldi and Sebastiano Vigna
3 * Copyright (C) 2003-2017 Paolo Boldi and Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Paolo Boldi and Sebastiano Vigna
3 * Copyright (C) 2003-2017 Paolo Boldi and Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Sebastiano Vigna
3 * Copyright (C) 2003-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Sebastiano Vigna
3 * Copyright (C) 2003-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Paolo Boldi and Sebastiano Vigna
3 * Copyright (C) 2003-2017 Paolo Boldi and Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2003-2016 Sebastiano Vigna
3 * Copyright (C) 2003-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2002-2016 Sebastiano Vigna
3 * Copyright (C) 2002-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil;
11
22 /*
3 * Copyright (C) 2010-2016 Sebastiano Vigna
3 * Copyright (C) 2010-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
00 package it.unimi.dsi.fastutil.io;
11
22 /*
3 * Copyright (C) 2005-2016 Sebastiano Vigna
3 * Copyright (C) 2005-2017 Sebastiano Vigna
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
433433
434434
435435 <li>A name clash between the list and collection interfaces
436 forces the deletion method of an collection to be named {@link
436 forces the deletion method of a collection to be named {@link
437437 it.unimi.dsi.fastutil.doubles.DoubleCollection#rem(double)
438438 rem()}. At the risk of creating some confusion, {@link
439439 it.unimi.dsi.fastutil.doubles.DoubleSet#remove(double) remove()}
441441 really unpleasant effect is that you must use
442442 <code>rem()</code> on variables that are collections, but not
443443 sets&mdash;for instance, {@linkplain
444 it.unimi.dsi.fastutil.ints.IntList type-specific lists}.
444 it.unimi.dsi.fastutil.ints.IntList type-specific lists}, and
445 that a subclass of a type-specific abstract collection must
446 override <code>rem()</code>, rather than <code>remove()</code>, to
447 make all inherited methods work properly.
445448
446449 <li>There are type-specific versions of {@link java.util.Comparator} that
447450 require specifying both a type-specific comparison method and an object-based
190190 }
191191
192192 }
193
194 public void testInts(int[] a) throws IOException {
195 final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
196 file.deleteOnExit();
197 for(int i = 0; i < a.length; i++) a[i] = i;
198 BinIO.storeInts(a, file);
199 assertArrayEquals(a, BinIO.loadInts(file));
200 }
201
202 @Test
203 public void testInts() throws IOException {
204 testInts(new int[1024]);
205 testInts(new int[1024 * 1024]);
206 }
193207 }
2323 @Override
2424 public boolean equals( Integer a, Integer b ) {
2525 if ( ( ( a == null ) != ( b == null ) ) || a == null ) return false;
26 return ( a.intValue() - b.intValue() % 10 ) == 0;
26 return ( (a.intValue() - b.intValue()) % 10 ) == 0;
2727 }
2828 });
2929