Commit graph

1866 commits

Author SHA1 Message Date
C. Sean Young
527927153f Fix a unintended format change 2021-02-01 10:30:43 -06:00
C. Sean Young
17eb657642 Fix AbstractMap containing a stack overflow containsValue
If both the default `containsValue` and the default `values` methods are
inherited by an implementating class, they will get a `StackOverflowError`
on trying to test for a value being present.

This is because the default `values().contains` calls `containsValue`, but
the default `containsValue` calls `values().contains`.

Now make the default `containsValues` loop over the entry set.

Add a comment that you should probably override this is your `values()`
has a better implementation. Same also retroactively applied to `containsKey`
and `keySet()`.

Finally, expands `AbstractInt2IntMapTest` to include the generic suite of tests
from `Int2IntMapGenericTest`, with a dummy testonly implementation that implements
the bare minimum for a mutable Int2Int map, to test as many of the `AbstractInt2IntMap`'s
default methods as possible.
2021-02-01 10:24:53 -06:00
C. Sean Young
480a1cbc16 Minor grammar fix in comments of OpenHashMap 2021-02-01 07:19:45 -06:00
C. Sean Young
c7a606f6bc Partial revert of commit 7615e085f5
Turns out, in the Java API and fastutil, there are no Itrator backed Spliterators
that actually gives the iterator to multiple splits, and thus the iterator will
never be used by multiple threads. This makes the iterator's thread safety, or
lack thereof, is a non-issue.

The overrides of spliterator where useful though, so those have been kept, just
now using fastiterator if possible.
2021-02-01 07:15:26 -06:00
C. Sean Young
a338b2a7dd Clarify that OpenHashMap's views' forEachRemaining are inherited 2021-01-31 22:31:37 -06:00
C. Sean Young
7615e085f5 Fix up unsafe uses of fastIterator backed Splitertors.
fastIterator, with its Entry sharing nature, is _thread hostile_. Not even external
locking can make it safe for use in parallel contexts. Thus you absolutely
should not wrap them in spliterators and then make a parallel stream on them.

This change fixes spliterators that were trying to wrap the fastIterator, and instead
makes them use the non fast iterator instead for spliterators.
(Other single thread only use cases continue to use the fastIterator if present).

Also puts various "big scary warnings" in places where FastIterators can be returned
to the user.
2021-01-31 22:15:29 -06:00
C. Sean Young
4ed7f94735 Fix many issues with map iteration and spliteration.
Fix issues where not all the ways to iterate `keySet` or `values` in a
LinkedOpenHashMap would follow the proper order (instead falling back to regular OpenHashMap order).

Make sure all OpenHashMap's (and their Linked and Custom cousins) views have proper iterators and spliterators,
saving a lot of implicit casts by the generics system.

Add unit tests for all these.
2021-01-31 21:12:04 -06:00
Sebastiano Vigna
a9711513ea Reversed loop 2021-01-31 17:46:43 +00:00
Sebastiano Vigna
b57c61a3bf Fixed wrong implementation of forEachRemaining() in hash-based containers 2021-01-31 16:50:23 +00:00
Sebastiano Vigna
7cef43b038 Added test for but in hash-based forEachRemaining() 2021-01-31 13:53:42 +00:00
Sebastiano Vigna
8e4db6044c Fixed Javadoc 2021-01-29 19:00:05 +00:00
Sebastiano Vigna
105863c040 Added missing disambiguation method for type-specific Map.merge() 2021-01-29 18:57:56 +00:00
Sebastiano Vigna
68af798238 Bumped revision 2021-01-29 18:31:59 +00:00
Sebastiano Vigna
16291fb19a Fixed bug in AbstractIndexBasedBigIterator 2021-01-29 16:50:21 +00:00
Sebastiano Vigna
b53b1e479f Bumped dates (again) 2021-01-29 14:39:19 +00:00
Sebastiano Vigna
56e4c27c3f Bumped dates 2021-01-29 14:30:07 +00:00
Sebastiano Vigna
4243c599dd Fixed types incompatible with javac 15 2021-01-29 15:12:35 +01:00
Sebastiano Vigna
b8e054291e Fixed warnings 2021-01-29 13:50:22 +00:00
Sebastiano Vigna
c375a73db4 Fixed Javadoc 2021-01-29 13:23:07 +00:00
Sebastiano Vigna
c8f0a59064
Merge pull request #228 from techsy730/SubListForImmutableList
Apply ArrayList.subList optimizations to BigArrayBigList
2021-01-27 12:41:54 +00:00
C. Sean Young
e25b96373c Merge branch 'master' of https://github.com/vigna/fastutil into SubListForImmutableList 2021-01-27 06:38:43 -06:00
Sebastiano Vigna
ed039451dc
Merge pull request #230 from techsy730/EmptyArrayListConstruction
Add a faster case if BigArrayBigList.of() (no arguments) is called.
2021-01-27 08:16:00 +00:00
C. Sean Young
80d0bb3bc2 Make ImmutableList.subList().spliterator().characteristics() report IMMUTABLE. 2021-01-26 19:15:16 -06:00
C. Sean Young
3afc5204f5 Add a faster case if BigArrayBigList.of() (no arguments) is called.
Instead of newly creating an empty BigArray, now it fallsback to the default constructor.
This will allow it to have much better resizing performance, as instead of 0->1 on first
add, it will go 0->10 (because of DEFAULT_EMPTY_BIG_ARRAY being used now).

The array based of remains the same, we need to ensure the same runtime type is kept,
even if empty.

Also minor doc updates to ArrayList as well.
2021-01-26 11:19:57 -06:00
C. Sean Young
ba2c34033a Make BigArrayBigList use backwards loops for equals methods.
According to BigArrays.equals, this is faster then the traditional
forwards loop for big arrays, at least in OpenJDK 8 and below (with Java 8 being our target version).
2021-01-26 10:54:04 -06:00
C. Sean Young
b84d1cc54e Minor comment fixes to IntArrayListTest and IntImmutableListTest 2021-01-26 10:01:17 -06:00
C. Sean Young
f65e07bc82 Also apply optimizations of ArrayList.subList to BigArrayBigList 2021-01-26 10:00:26 -06:00
Sebastiano Vigna
63e521272b Fixed warnings 2021-01-25 14:37:02 +00:00
Sebastiano Vigna
8f2345650e
Merge pull request #226 from techsy730/SubListForImmutableList
Sub list for immutable list
2021-01-25 13:40:19 +00:00
C. Sean Young
d03ccaaea0 Add comment about no validation to ImmutableSubList constructor 2021-01-24 14:57:04 -06:00
C. Sean Young
b7b7a2041e Also apply equals and compareTo optimizations to SubList of ArrayList 2021-01-24 12:11:37 -06:00
C. Sean Young
49b56ecfb1 Test compareTo, make sublist serializable 2021-01-24 12:11:01 -06:00
C. Sean Young
4b6fbfb142 Merge remote-tracking branch 'mainline/master' into SubListForImmutableList 2021-01-24 10:39:29 -06:00
Sebastiano Vigna
1706b5323b
Merge pull request #225 from techsy730/ImmutableListEqualsFix
Fix a rather critical bug where ImmutableList.equals would return true erroneosly
2021-01-24 16:26:48 +00:00
Sebastiano Vigna
c772ca9e05
Merge pull request #227 from techsy730/KeyReferenceEqualityMacro
Replace KEY_CLASS_Reference with KEYS_USE_REFERENCE_EQUALITY
2021-01-24 16:26:27 +00:00
C. Sean Young
bed6b8f8c1 Replace KEY_CLASS_Reference with KEYS_USE_REFERENCE_EQUALITY
This is much clearer that we mean the types that use `==` for equality
testing instead of `.equals`, and not confuse it with `KEYS_REFERENCE`
macro which means any types using Object backed members.

Also documents the gotcha of trying to use a Reference based and a
non-Reference based type together (e.g. you may get non symmetric `equals`)

Also does the same for VALUE.
2021-01-23 12:55:59 -06:00
C. Sean Young
4eb48e0a6f Make ArrayList.equals(ArrayList) (and compareTo) use @apiNote as well 2021-01-23 11:38:45 -06:00
C. Sean Young
f2b6cf2275 Fix some compilation issues and add tests for ImmutableSubList 2021-01-23 11:38:01 -06:00
C. Sean Young
714a52eb15 Merge branch 'ImmutableListEqualsFix' into SubListForImmutableList 2021-01-23 10:52:01 -06:00
C. Sean Young
4e83b6dd1d Fix a rather critical bug where ImmutableList.equals would return true erroneosly
Would happen to return true if any ImmutableList was given, equal contents or not.
2021-01-23 10:45:06 -06:00
C. Sean Young
de649a5e6f Add a fast subList for ImmutableList.
Currently ImmutableList.subList doesn't return an ImmutableList itself
due to the current implementation of ImmutableList being closely tied to
the idea the full array is the whole list.
This may change in a future release.
2021-01-23 10:41:54 -06:00
Sebastiano Vigna
70cad024ed
Merge pull request #222 from techsy730/RandomAccessListSpliterator
Fix a missing import that was breaking Javadocs
2021-01-15 11:59:24 +00:00
C. Sean Young
427393a2d1 Fix a missing import that was breaking Javadocs 2021-01-15 05:56:21 -06:00
Sebastiano Vigna
6bacc89907 Redefined compilation conditionals for deprecated merge method 2021-01-15 11:40:03 +00:00
Sebastiano Vigna
49eec2df43
Merge pull request #220 from techsy730/RandomAccessListSpliterator
Further document the spliterator methods in interfaces.
2021-01-15 11:12:56 +00:00
C. Sean Young
e30c9e0e26 Give the name of the type instead of calling them all collection. 2021-01-14 21:44:02 -06:00
C. Sean Young
69f62286d5 Also document spliterator() of BigList. 2021-01-14 21:43:39 -06:00
C. Sean Young
99fc1dfdc6 Further mention the requirement the getComparator requirements. 2021-01-14 21:25:21 -06:00
C. Sean Young
2a26121fb7 Fix wrong link in SortedSet. 2021-01-14 21:22:07 -06:00
C. Sean Young
dc0aff809b Merge branch 'master' of https://github.com/vigna/fastutil into RandomAccessListSpliterator 2021-01-14 21:07:44 -06:00