Delegates to the corresponding type-specific method.
45 | * @deprecated Please use the corresponding type-specific method instead. */
46 | @Deprecated
47 | @Override
48 | ```
49 |
50 | * Ideally, the abstract class should implement the type-specific
51 | methods following the example of the Java Collections Framework.
52 | For example,
53 | ```java
54 | /** {@inheritDoc}
55 | *
This implementation just throws an {@link UnsupportedOperationException}. */
56 | @Override
57 | ```
58 |
59 | Obsolete type-specific methods
60 | ------------------------------
61 |
62 | Obsolete methods such as `intIterator()` should be marked in interfaces
63 | as deprecated and documented with a pointer
64 | ```java
65 | /** Returns a type-specific iterator on this elements of this collection.
66 | *
67 | * @see #iterator()
68 | * @deprecated As of fastutil 5, replaced by {@link #iterator()}.
69 | */
70 | @Deprecated
71 | ```
72 |
73 | Whenever these methods are implemented, the deprecation must be propagated.
74 |
75 | ```java
76 | /** @{inheritDoc}
77 | * @deprecated As of fastutil 5, replaced by {@link #iterator()}. */
78 | @Deprecated
79 | @Override
80 | ```
81 |
82 | Unnecessary methods
83 | -------------------
84 |
85 | Over the years, a number of duplicate methods have been implemented
86 | (e.g., standard versions of type-specific methods). For clarity
87 | and simplicity, no unnecessary method should be implemented. In doubt,
88 | follow the example of the JDK.
89 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | - Buffer bulk methods with index to get rid of mapped buffer duplication
2 | - Loops in sorting for big arrays should use real indices, not get/set
3 | - Check that binary insertion sort is maybe better
4 | - radix sort for big arrays
5 | - Navigable sets and maps
6 | - Make digit array in radix sort shorter
7 | - FastIterable interface
8 | - Try tripartite quickSort or TimSort for generic sorting.
9 | - http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html
10 | - http://java-performance.info/large-hashmap-overview-jdk-fastutil-goldman-sachs-hppc-koloboke-trove
11 | - http://shipilev.net/
12 | - http://java-performance.info/jmh/
13 | - Big maps
14 | - Cilksort
15 | - Tune threshold for non-recursive sorts
16 | - parallel indirect radix sort of two arrays
17 | - Better remove() from keyset (avoid in all possible cases inheritance from AbstractSet!)
18 | - Eliminate ping-pong implementations (look for "delegates to the corresponding generic method")
19 | - Fix comparator() in SortedSet not being specified in the same way as in SortedMap
20 | - Document the return value of map generic methods (null? default return value?).
21 | - XBigArrays.unstableSort for automatic algorithm selection like XArrays.unstableSort
22 | - BigList.unstableSort method
23 | - addTo() etc. on numeric interfaces
24 | - peek() method for ArrayFIFOQueue.
25 | - Spliterator implementations for RBTreeSet/Map, AVLTreeSet/Map, and ArrayFrontCodedLists
26 | - Implement type-specific Iterator views of Spliterator (aka, Spliterators.iterator(Spliterator))
27 | - Find a cleaner way to deal with the disambiguation overloads
28 | aka. get rid of the forEachRemaining(it.unimi.dsi.fastutil.ints.IntConsumer) style methods and the SpliteratorDisambiguationMethodsFinalShim style classes
29 | - Primitive collector helper methods, collecting a primitive stream into list or set without boxing/unboxing
30 | - Don't have a N-nested sublist of ArrayList.get go through N layers of get methods
31 | remove and add will have to continue to do this so all parent sublists can adjust their bounds,
32 | but get can just short circuit to the parent list's array if we track bounds correctly
33 | - toBigArray for BigList (or maybe a new BigCollection)
34 | - Make the recursive algorithms of BigArrays and the type specific BigArrays prefer aligning to segment boundaries
35 | This should improve cache locality
36 | - Make constructors consistent across types (make it so all Collection types can accept a Collection, an array, an Iterable, and an Iterator)
37 | - Add array copying constructors (or perhaps static factories) for ArraySet
38 | The current one just uses the array exactly, when in some cases a copy of that array may be desired
39 | We can't change the current one without breaking compatibility
40 | - For classes that have a main() method for testing instead of a JUnit test, either migrate it to JUnit or make a JUnit test that just calls the in class's test method
41 | This should make it easier to get more accurate code coverage data.
42 | - Update all benchmarks with the framework ArraySet and ArrayList have
43 | - Pull `if (n < 0) throw new IllegalArgumentException("Argument must be nonnegative: " + n);` into a helper method, since it is used so much
44 | - Convert the tests in main methods (if TEST=1 is given to make) into real unit tests
45 | - Similarly, pull the benchmarks into their own files
46 |
--------------------------------------------------------------------------------
/bnd/biz.aQute.bnd-5.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vigna/fastutil/eeca53120ef1e35172c14aed53a643516eeaf3f5/bnd/biz.aQute.bnd-5.2.0.jar
--------------------------------------------------------------------------------
/build.properties:
--------------------------------------------------------------------------------
1 | jar.base=/usr/share/java
2 | javadoc.base=/usr/share/javadoc
3 |
4 | build.sysclasspath=ignore
5 |
6 | version=8.5.15
7 |
8 | dist=dist
9 | src=src
10 | drv=drv
11 | test=test
12 | reports=reports
13 | coverage=coverage
14 | checkstyle=checkstyle
15 | docs=docs
16 | build=build
17 | instrumented=instrumented
18 |
19 | remote.j2se.apiurl=https://docs.oracle.com/javase/8/docs/api/
20 |
--------------------------------------------------------------------------------
/drv/AbstractBidirectionalIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific {@linkplain it.unimi.dsi.fastutil.BidirectionalIterator bidirectional iterators}.
21 | *
22 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its previous abstract
23 | * methods are now default methods of the type-specific interface.
24 | */
25 |
26 | @Deprecated
27 | public abstract class KEY_ABSTRACT_BIDI_ITERATOR KEY_GENERIC extends KEY_ABSTRACT_ITERATOR KEY_GENERIC implements KEY_BIDI_ITERATOR KEY_GENERIC {
28 | protected KEY_ABSTRACT_BIDI_ITERATOR() {}
29 | }
30 |
--------------------------------------------------------------------------------
/drv/AbstractBigListIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific {@linkplain it.unimi.dsi.fastutil.BigListIterator big-list iterators}.
21 | *
22 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its previous abstract
23 | * methods are now default methods of the type-specific interface.
24 | */
25 |
26 | @Deprecated
27 | public abstract class KEY_ABSTRACT_BIG_LIST_ITERATOR KEY_GENERIC extends KEY_ABSTRACT_BIDI_ITERATOR KEY_GENERIC implements KEY_BIG_LIST_ITERATOR KEY_GENERIC {
28 | protected KEY_ABSTRACT_BIG_LIST_ITERATOR() {}
29 | }
30 |
--------------------------------------------------------------------------------
/drv/AbstractComparator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific {@linkplain java.util.Comparator comparators}.
21 | *
22 | * @see java.util.Comparator
23 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its only previous abstract
24 | * method is now a default method of the type-specific interface.
25 | */
26 |
27 | @Deprecated
28 | public abstract class KEY_ABSTRACT_COMPARATOR KEY_GENERIC implements KEY_COMPARATOR KEY_GENERIC, java.io.Serializable {
29 | private static final long serialVersionUID = 0L;
30 | protected KEY_ABSTRACT_COMPARATOR() {}
31 | }
32 |
--------------------------------------------------------------------------------
/drv/AbstractFunction.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class providing basic methods for functions implementing a type-specific interface.
21 | *
22 | *
This class handles directly a default return
23 | * value (including {@linkplain #defaultReturnValue() methods to access
24 | * it}). Instances of classes inheriting from this class have just to return
25 | * {@code defRetValue} to denote lack of a key in type-specific methods. The value
26 | * is serialized.
27 | *
28 | *
Implementing subclasses have just to provide type-specific {@code get()},
29 | * type-specific {@code containsKey()}, and {@code size()} methods.
30 | *
31 | */
32 |
33 | public abstract class ABSTRACT_FUNCTION KEY_VALUE_GENERIC implements FUNCTION KEY_VALUE_GENERIC, java.io.Serializable {
34 |
35 | private static final long serialVersionUID = -4940583368468432370L;
36 |
37 | protected ABSTRACT_FUNCTION() {}
38 |
39 | /**
40 | * The default return value for {@code get()}, {@code put()} and
41 | * {@code remove()}.
42 | */
43 |
44 | protected VALUE_GENERIC_TYPE defRetValue;
45 |
46 | @Override
47 | public void defaultReturnValue(final VALUE_GENERIC_TYPE rv) {
48 | defRetValue = rv;
49 | }
50 |
51 | @Override
52 | public VALUE_GENERIC_TYPE defaultReturnValue() {
53 | return defRetValue;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/drv/AbstractIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific iterators.
21 | *
22 | * @apiNote Up to version 8.5.0, this class was deprecated as abstract methods were
23 | * turned into default methods of the type-specific interface. Now the class hosts
24 | * finalized versions of default delegating methods such as {@link #forEachRemaining}.
25 | */
26 |
27 | public abstract class KEY_ABSTRACT_ITERATOR KEY_GENERIC implements KEY_ITERATOR KEY_GENERIC {
28 | protected KEY_ABSTRACT_ITERATOR() {}
29 |
30 | #if KEYS_INT_LONG_DOUBLE
31 | /** {@inheritDoc}
32 | * @implSpec This method just delegates to the interface default method,
33 | * as the default method, but it is final, so it cannot be overridden.
34 | */
35 | @Override
36 | public final void forEachRemaining(final KEY_CONSUMER action) {
37 | forEachRemaining((JDK_PRIMITIVE_KEY_CONSUMER) action);
38 | }
39 | #endif
40 | }
41 |
--------------------------------------------------------------------------------
/drv/AbstractListIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific {@linkplain java.util.ListIterator list iterators}.
21 | *
22 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its previous abstract
23 | * methods are now default methods of the type-specific interface.
24 | */
25 |
26 | @Deprecated
27 | public abstract class KEY_ABSTRACT_LIST_ITERATOR KEY_GENERIC extends KEY_ABSTRACT_BIDI_ITERATOR KEY_GENERIC implements KEY_LIST_ITERATOR KEY_GENERIC {
28 | protected KEY_ABSTRACT_LIST_ITERATOR() {}
29 | }
30 |
--------------------------------------------------------------------------------
/drv/AbstractPriorityQueue.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class providing basic methods for priority queues implementing a type-specific interface.
21 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its previous abstract
22 | * methods are now default methods of the type-specific interface.
23 | */
24 | @Deprecated
25 | public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC extends it.unimi.dsi.fastutil.AbstractPriorityQueue implements java.io.Serializable, PRIORITY_QUEUE KEY_GENERIC {
26 | private static final long serialVersionUID = 1L;
27 | }
28 |
--------------------------------------------------------------------------------
/drv/AbstractSet.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import java.util.Set;
21 |
22 | /** An abstract class providing basic methods for sets implementing a type-specific interface.
23 | *
24 | *
Note that the type-specific {@link Set} interface adds a type-specific {@code remove()}
25 | * method, as it is no longer harmful for subclasses. Thus, concrete subclasses of this class
26 | * must implement {@code remove()} (the {@code rem()} implementation of this
27 | * class just delegates to {@code remove()}).
28 | */
29 |
30 | public abstract class ABSTRACT_SET KEY_GENERIC extends ABSTRACT_COLLECTION KEY_GENERIC implements Cloneable, SET KEY_GENERIC {
31 |
32 | protected ABSTRACT_SET() {}
33 |
34 | @Override
35 | public abstract KEY_ITERATOR KEY_GENERIC iterator();
36 |
37 | @Override
38 | public boolean equals(final Object o) {
39 | if (o == this) return true;
40 | if (!(o instanceof Set)) return false;
41 |
42 | Set> s = (Set>) o;
43 | if (s.size() != size()) return false;
44 | #if KEYS_PRIMITIVE
45 | if (s instanceof SET) {
46 | return containsAll((SET) s);
47 | }
48 | #endif
49 | return containsAll(s);
50 | }
51 |
52 |
53 | /** Returns a hash code for this set.
54 | *
55 | * The hash code of a set is computed by summing the hash codes of
56 | * its elements.
57 | *
58 | * @return a hash code for this set.
59 | */
60 | @Override
61 | public int hashCode() {
62 | int h = 0, n = size();
63 | KEY_ITERATOR KEY_GENERIC i = iterator();
64 | KEY_GENERIC_TYPE k;
65 |
66 | while(n-- != 0) {
67 | k = i.NEXT_KEY(); // We need k because KEY2JAVAHASH() is a macro with repeated evaluation.
68 | h += KEY2JAVAHASH(k);
69 | }
70 | return h;
71 | }
72 |
73 |
74 | #if KEYS_PRIMITIVE
75 | /** {@inheritDoc}
76 | * Delegates to the type-specific {@code rem()} method
77 | * implemented by type-specific abstract {@link java.util.Collection} superclass.
78 | */
79 | @Override
80 | public boolean remove(KEY_TYPE k) {
81 | return super.rem(k);
82 | }
83 |
84 | /** {@inheritDoc}
85 | * Delegates to the type-specific {@code remove()} method
86 | * specified in the type-specific {@link Set} interface.
87 | * @deprecated Please use {@code remove()} instead.
88 | */
89 | @Deprecated
90 | @Override
91 | public boolean rem(KEY_TYPE k) {
92 | return remove(k);
93 | }
94 | #endif
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/drv/AbstractSortedSet.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class providing basic methods for sorted sets implementing a type-specific interface. */
21 |
22 | public abstract class ABSTRACT_SORTED_SET KEY_GENERIC extends ABSTRACT_SET KEY_GENERIC implements SORTED_SET KEY_GENERIC {
23 |
24 | protected ABSTRACT_SORTED_SET() {}
25 |
26 | @Override
27 | public abstract KEY_BIDI_ITERATOR KEY_GENERIC iterator();
28 | }
29 |
--------------------------------------------------------------------------------
/drv/AbstractSpliterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class facilitating the creation of type-specific iterators.
21 | *
22 | * @apiNote Presently the class hosts
23 | * finalized versions of default delegating methods such as {@link #forEachRemaining}.
24 | */
25 |
26 | public abstract class KEY_ABSTRACT_SPLITERATOR KEY_GENERIC implements KEY_SPLITERATOR KEY_GENERIC {
27 | protected KEY_ABSTRACT_SPLITERATOR() {}
28 |
29 | #if KEYS_INT_LONG_DOUBLE
30 | /** {@inheritDoc}
31 | * @implSpec This method just delegates to the interface default method,
32 | * as the default method, but it is final, so it cannot be overridden.
33 | */
34 | @Override
35 | public final boolean tryAdvance(final KEY_CONSUMER action) {
36 | // Java won't let delegate to java.util.Spliterator.OfInt
37 | return tryAdvance((JDK_PRIMITIVE_KEY_CONSUMER) action);
38 | }
39 |
40 | /** {@inheritDoc}
41 | * @implSpec This method just delegates to the interface default method,
42 | * as the default method, but it is final, so it cannot be overridden.
43 | */
44 | @Override
45 | public final void forEachRemaining(final KEY_CONSUMER action) {
46 | forEachRemaining((JDK_PRIMITIVE_KEY_CONSUMER) action);
47 | }
48 | #endif
49 | }
50 |
--------------------------------------------------------------------------------
/drv/AbstractStack.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** An abstract class providing basic methods for implementing a type-specific stack interface.
21 | *
22 | * @deprecated As of {@code fastutil} 8 this class is no longer necessary, as its previous abstract
23 | * methods are now default methods of the type-specific interface.
24 | */
25 | @Deprecated
26 | public abstract class ABSTRACT_STACK KEY_GENERIC extends it.unimi.dsi.fastutil.AbstractStack implements STACK KEY_GENERIC {
27 | protected ABSTRACT_STACK() {}
28 | }
29 |
--------------------------------------------------------------------------------
/drv/BidirectionalIterable.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** A type-specific {@link Iterable} that further strengthens the specification of {@link Iterable#iterator()}.
21 | */
22 | public interface KEY_BIDI_ITERABLE KEY_GENERIC extends KEY_ITERABLE KEY_GENERIC {
23 |
24 | /** Returns a type-specific {@link it.unimi.dsi.fastutil.BidirectionalIterator}.
25 | *
26 | * @return a type-specific bidirectional iterator.
27 | */
28 | @Override
29 | KEY_BIDI_ITERATOR KEY_GENERIC iterator();
30 | }
31 |
--------------------------------------------------------------------------------
/drv/BidirectionalIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import it.unimi.dsi.fastutil.BidirectionalIterator;
21 | #if KEYS_PRIMITIVE
22 | import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator;
23 | #endif
24 |
25 | /** A type-specific bidirectional iterator; provides an additional method to avoid (un)boxing,
26 | * and the possibility to skip elements backwards.
27 | *
28 | * @see BidirectionalIterator
29 | */
30 |
31 | #if KEYS_PRIMITIVE
32 | public interface KEY_BIDI_ITERATOR KEY_GENERIC extends KEY_ITERATOR KEY_GENERIC, ObjectBidirectionalIterator {
33 | #else
34 | public interface KEY_BIDI_ITERATOR KEY_GENERIC extends KEY_ITERATOR KEY_GENERIC, BidirectionalIterator {
35 | #endif
36 |
37 | #if KEYS_PRIMITIVE
38 |
39 | /**
40 | * Returns the previous element as a primitive type.
41 | *
42 | * @return the previous element in the iteration.
43 | * @see java.util.ListIterator#previous()
44 | */
45 |
46 | KEY_TYPE PREV_KEY();
47 |
48 | /** {@inheritDoc}
49 | * @deprecated Please use the corresponding type-specific method instead. */
50 | @Deprecated
51 | @Override
52 | default KEY_GENERIC_CLASS previous() { return KEY_CLASS.valueOf(PREV_KEY()); }
53 |
54 | #endif
55 |
56 | /** Moves back for the given number of elements.
57 | *
58 | *
The effect of this call is exactly the same as that of
59 | * calling {@link #previous()} for {@code n} times (possibly stopping
60 | * if {@link #hasPrevious()} becomes false).
61 | *
62 | * @param n the number of elements to skip back.
63 | * @return the number of elements actually skipped.
64 | * @see #previous()
65 | */
66 | #if KEYS_PRIMITIVE
67 | @Override
68 | #endif
69 | default int back(final int n) {
70 | int i = n;
71 | while(i-- != 0 && hasPrevious()) PREV_KEY();
72 | return n - i - 1;
73 | }
74 |
75 | /** {@inheritDoc} */
76 | @Override
77 | default int skip(final int n) {
78 | return KEY_ITERATOR.super.skip(n);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/drv/BigListIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import it.unimi.dsi.fastutil.BigListIterator;
21 | import it.unimi.dsi.fastutil.SafeMath;
22 |
23 | /** A type-specific {@link BigListIterator}.
24 | *
25 | * @see BigListIterator
26 | */
27 |
28 | public interface KEY_BIG_LIST_ITERATOR KEY_GENERIC extends KEY_BIDI_ITERATOR KEY_GENERIC, BigListIterator {
29 |
30 | /**
31 | * Replaces the last element returned by {@link BigListIterator#next() next()} or
32 | * {@link BigListIterator#previous() previous()} with the specified element (optional operation).
33 | * @see java.util.ListIterator#set(Object)
34 | */
35 |
36 | #if KEYS_REFERENCE
37 | @Override
38 | #endif
39 | default void set(@SuppressWarnings("unused") final KEY_GENERIC_TYPE k) { throw new UnsupportedOperationException(); }
40 |
41 | /**
42 | * Inserts the specified element into the list (optional operation).
43 | * @see java.util.ListIterator#add(Object)
44 | */
45 |
46 | #if KEYS_REFERENCE
47 | @Override
48 | #endif
49 | default void add(@SuppressWarnings("unused") final KEY_GENERIC_TYPE k) { throw new UnsupportedOperationException(); }
50 |
51 | #if KEYS_PRIMITIVE
52 |
53 | /** Replaces the last element returned by {@link #next()} or {@link #previous()} with the specified element (optional operation).
54 | * @deprecated Please use the corresponding type-specific method instead. */
55 | @Deprecated
56 | @Override
57 | default void set(final KEY_GENERIC_CLASS k) { set(k.KEY_VALUE()); }
58 |
59 | /** Inserts the specified element into the list (optional operation).
60 | * @deprecated Please use the corresponding type-specific method instead. */
61 | @Deprecated
62 | @Override
63 | default void add(final KEY_GENERIC_CLASS k) { add(k.KEY_VALUE()); }
64 |
65 | #endif
66 |
67 |
68 | /** Skips the given number of elements.
69 | *
70 | *
The effect of this call is exactly the same as that of
71 | * calling {@link BigListIterator#next() next()} for {@code n} times (possibly stopping
72 | * if {@link #hasNext()} becomes false).
73 | *
74 | * @param n the number of elements to skip.
75 | * @return the number of elements actually skipped.
76 | * @see BigListIterator#next()
77 | */
78 | default long skip(final long n) {
79 | long i = n;
80 | while(i-- != 0 && hasNext()) NEXT_KEY();
81 | return n - i - 1;
82 | }
83 |
84 | /** Moves back for the given number of elements.
85 | *
86 | *
The effect of this call is exactly the same as that of
87 | * calling {@link BigListIterator#previous() previous()} for {@code n} times (possibly stopping
88 | * if {@link #hasPrevious()} becomes false).
89 | *
90 | * @param n the number of elements to skip back.
91 | * @return the number of elements actually skipped.
92 | * @see BigListIterator#previous()
93 | */
94 | default long back(final long n) {
95 | long i = n;
96 | while(i-- != 0 && hasPrevious()) PREV_KEY();
97 | return n - i - 1;
98 | }
99 |
100 | /** {@inheritDoc}
101 | */
102 | @Override
103 | default int skip(int n) {
104 | return SafeMath.safeLongToInt(skip((long) n));
105 | }
106 | }
--------------------------------------------------------------------------------
/drv/BinaryOperator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import java.util.function.BinaryOperator;
21 |
22 | /** A type-specific {@link BinaryOperator}; provides methods operating both on objects
23 | * and on primitives.
24 | *
25 | * @see BinaryOperator
26 | * @since 8.5.0
27 | */
28 |
29 | @FunctionalInterface
30 | #if ! KEY_CLASS_Boolean
31 | public interface KEY_BINARY_OPERATOR KEY_GENERIC extends BinaryOperator, JDK_PRIMITIVE_BINARY_OPERATOR {
32 | #else
33 | public interface KEY_BINARY_OPERATOR KEY_GENERIC extends BinaryOperator {
34 | #endif
35 |
36 | /**
37 | * Computes the operator on the given inputs.
38 | *
39 | * @param x the first input.
40 | * @param y the second input.
41 | * @return the output of the operator on the given inputs.
42 | */
43 | KEY_TYPE apply(KEY_TYPE x, KEY_TYPE y);
44 |
45 | #if KEYS_INT_LONG_DOUBLE
46 | /** {@inheritDoc}
47 | *
48 | * @implSpec This default implementation delegates to {@link #apply}.
49 | * @deprecated Please use {@link #apply}.
50 | */
51 | #else
52 | /** {@inheritDoc}
53 | *
54 | * @implSpec This default implementation delegates to
55 | * {@link #apply} after narrowing down the arguments to the
56 | * actual key type, throwing an exception if the arguments cannot be
57 | * represented in the restricted domain. This is done for interoperability
58 | * with the Java 8 function environment. The use of this method discouraged, as
59 | * unexpected errors can occur.
60 | *
61 | * @throws IllegalArgumentException If the given operands are not an element of the key domain.
62 | * @since 8.5.0
63 | * @deprecated Please use {@link #apply}.
64 | */
65 | #endif
66 |
67 | #if ! KEY_CLASS_Boolean
68 | @Deprecated
69 | @Override
70 | default KEY_TYPE_WIDENED JDK_PRIMITIVE_BINARY_OPERATOR_APPLY(final KEY_TYPE_WIDENED x, final KEY_TYPE_WIDENED y) {
71 | return apply(KEY_NARROWING(x), KEY_NARROWING(y));
72 | }
73 | #endif
74 |
75 | /** {@inheritDoc}
76 | * @deprecated Please use the corresponding type-specific method instead. */
77 | @Deprecated
78 | @Override
79 | @SuppressWarnings("boxing")
80 | default KEY_CLASS apply(final KEY_CLASS x, final KEY_CLASS y) {
81 | return apply(x.KEY_VALUE(), y.KEY_VALUE());
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/drv/Hash.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import it.unimi.dsi.fastutil.Hash;
21 |
22 | /** A type-specific {@link Hash} interface.
23 | *
24 | * @see Hash
25 | */
26 |
27 | public interface HASH {
28 |
29 | /** A type-specific hash strategy.
30 | *
31 | * @see it.unimi.dsi.fastutil.Hash.Strategy
32 | */
33 |
34 | interface Strategy {
35 |
36 | /** Returns the hash code of the specified element with respect to this hash strategy.
37 | *
38 | * @param e an element.
39 | * @return the hash code of the given element with respect to this hash strategy.
40 | */
41 |
42 | int hashCode(KEY_TYPE e);
43 |
44 | /** Returns true if the given elements are equal with respect to this hash strategy.
45 | *
46 | * @param a an element.
47 | * @param b another element.
48 | * @return true if the two specified elements are equal with respect to this hash strategy.
49 | */
50 |
51 | boolean equals(KEY_TYPE a, KEY_TYPE b);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/drv/ImmutablePair.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** A type-specific immutable {@link it.unimi.dsi.fastutil.Pair Pair}; provides some additional methods that use polymorphism to avoid (un)boxing. */
21 |
22 | public class IMMUTABLE_PAIR KEY_VALUE_GENERIC implements PAIR KEY_VALUE_GENERIC, java.io.Serializable {
23 | private static final long serialVersionUID = 0L;
24 |
25 | protected final KEY_GENERIC_TYPE left;
26 | protected final VALUE_GENERIC_TYPE right;
27 |
28 | /** Creates a new type-specific immutable {@link it.unimi.dsi.fastutil.Pair Pair} with given left and right value.
29 | * @param left the left value.
30 | * @param right the right value.
31 | */
32 | public IMMUTABLE_PAIR(final KEY_GENERIC_TYPE left, final VALUE_GENERIC_TYPE right) {
33 | this.left = left;
34 | this.right = right;
35 | }
36 |
37 | /** Returns a new type-specific immutable {@link it.unimi.dsi.fastutil.Pair Pair} with given left and right value.
38 | * @param left the left value.
39 | * @param right the right value.
40 | *
41 | * @implSpec This factory method delegates to the constructor.
42 | */
43 | public static KEY_VALUE_GENERIC IMMUTABLE_PAIR KEY_VALUE_GENERIC of(final KEY_GENERIC_TYPE left, final VALUE_GENERIC_TYPE right) {
44 | return new IMMUTABLE_PAIR KEY_VALUE_GENERIC(left, right);
45 | }
46 |
47 | @Override
48 | public KEY_GENERIC_TYPE PAIR_LEFT() {
49 | return left;
50 | }
51 |
52 | @Override
53 | public VALUE_GENERIC_TYPE PAIR_RIGHT() {
54 | return right;
55 | }
56 |
57 | @Override
58 | @SuppressWarnings("rawtypes")
59 | public boolean equals(Object other) {
60 | if (other == null) return false;
61 |
62 | #if KEYS_PRIMITIVE || VALUES_PRIMITIVE
63 | if (other instanceof PAIR) {
64 | return
65 |
66 | #if KEY_CLASS_Object
67 | java.util.Objects.equals(left, ((PAIR)other).PAIR_LEFT())
68 | #else
69 | left == ((PAIR)other).PAIR_LEFT()
70 | #endif
71 | #if VALUE_CLASS_Object
72 | && java.util.Objects.equals(right, ((PAIR)other).PAIR_RIGHT());
73 | #else
74 | && right == ((PAIR)other).PAIR_RIGHT();
75 | #endif
76 | }
77 | #endif
78 |
79 | if (other instanceof it.unimi.dsi.fastutil.Pair) {
80 | return
81 | #if KEYS_USE_REFERENCE_EQUALITY
82 | left == ((it.unimi.dsi.fastutil.Pair)other).left()
83 | #else
84 | java.util.Objects.equals(KEY2OBJ(left), ((it.unimi.dsi.fastutil.Pair)other).left())
85 | #endif
86 | #if VALUES_USE_REFERENCE_EQUALITY
87 | && right == ((it.unimi.dsi.fastutil.Pair)other).right();
88 | #else
89 | && java.util.Objects.equals(VALUE2OBJ(right), ((it.unimi.dsi.fastutil.Pair)other).right());
90 | #endif
91 | }
92 |
93 | return false;
94 | }
95 |
96 | @Override
97 | public int hashCode() {
98 | return KEY2JAVAHASH(left) * 19 + VALUE2JAVAHASH(right);
99 | }
100 |
101 | /** Returns a string representation of this pair in the form <l,r>.
102 | *
103 | * @return a string representation of this pair in the form <l,r>.
104 | */
105 | @Override
106 | public String toString() {
107 | return "<" + PAIR_LEFT() + "," + PAIR_RIGHT() + ">";
108 | }
109 | }
--------------------------------------------------------------------------------
/drv/ImmutableSortedPair.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** A type-specific immutable {@link it.unimi.dsi.fastutil.SortedPair SortedPair}; provides some additional methods that use polymorphism to avoid (un)boxing. */
21 |
22 | #if KEYS_PRIMITIVE
23 | public class IMMUTABLE_SORTED_PAIR extends IMMUTABLE_PAIR implements SORTED_PAIR, java.io.Serializable {
24 | #else
25 | public class IMMUTABLE_SORTED_PAIR > extends IMMUTABLE_PAIR implements it.unimi.dsi.fastutil.SortedPair, java.io.Serializable {
26 | #endif
27 | private static final long serialVersionUID = 0L;
28 |
29 | private IMMUTABLE_SORTED_PAIR(final KEY_GENERIC_TYPE left, final KEY_GENERIC_TYPE right) {
30 | super(left, right);
31 | }
32 |
33 | /** Returns a new type-specific immutable {@link it.unimi.dsi.fastutil.SortedPair SortedPair} with given left and right value.
34 | *
35 | *
Note that if {@code left} and {@code right} are in the wrong order, they will be exchanged.
36 | *
37 | * @param left the left value.
38 | * @param right the right value.
39 | *
40 | * @implSpec This factory method delegates to the constructor.
41 | */
42 | #if KEYS_PRIMITIVE
43 | public static IMMUTABLE_SORTED_PAIR of(final KEY_GENERIC_TYPE left, final KEY_GENERIC_TYPE right) {
44 | if (left <= right) return new IMMUTABLE_SORTED_PAIR(left, right);
45 | else return new IMMUTABLE_SORTED_PAIR(right, left);
46 | #else
47 | public static > IMMUTABLE_SORTED_PAIR of(final KEY_GENERIC_TYPE left, final KEY_GENERIC_TYPE right) {
48 | if (left.compareTo(right) <= 0) return new IMMUTABLE_SORTED_PAIR (left, right);
49 | else return new IMMUTABLE_SORTED_PAIR (right, left);
50 | #endif
51 | }
52 |
53 | @Override
54 | @SuppressWarnings("rawtypes")
55 | public boolean equals(Object other) {
56 | if (other == null) return false;
57 |
58 | #if KEYS_PRIMITIVE || VALUES_PRIMITIVE
59 | if (other instanceof SORTED_PAIR) {
60 | return
61 |
62 | #if KEY_CLASS_Object
63 | java.util.Objects.equals(left, ((SORTED_PAIR)other).PAIR_LEFT())
64 | #else
65 | left == ((SORTED_PAIR)other).PAIR_LEFT()
66 | #endif
67 | #if VALUE_CLASS_Object
68 | && java.util.Objects.equals(right, ((SORTED_PAIR)other).PAIR_RIGHT());
69 | #else
70 | && right == ((SORTED_PAIR)other).PAIR_RIGHT();
71 | #endif
72 | }
73 | #endif
74 |
75 | if (other instanceof it.unimi.dsi.fastutil.SortedPair) {
76 | return
77 | #if KEYS_USE_REFERENCE_EQUALITY
78 | left == ((it.unimi.dsi.fastutil.SortedPair)other).left()
79 | #else
80 | java.util.Objects.equals(KEY2OBJ(left), ((it.unimi.dsi.fastutil.SortedPair)other).left())
81 | #endif
82 | #if VALUES_USE_REFERENCE_EQUALITY
83 | && right == ((it.unimi.dsi.fastutil.SortedPair)other).right();
84 | #else
85 | && java.util.Objects.equals(VALUE2OBJ(right), ((it.unimi.dsi.fastutil.SortedPair)other).right());
86 | #endif
87 | }
88 |
89 | return false;
90 | }
91 |
92 | /** Returns a string representation of this sorted pair in the form {l,r}.
93 | *
94 | * @return a string representation of this pair sorted in the form {l,r}.
95 | */
96 | @Override
97 | public String toString() {
98 | return "{" + PAIR_LEFT() + "," + PAIR_RIGHT() + "}";
99 | }
100 | }
--------------------------------------------------------------------------------
/drv/IndirectPriorityQueue.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003-2024 Paolo Boldi and Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import it.unimi.dsi.fastutil.IndirectPriorityQueue;
21 |
22 | /** A type-specific {@link IndirectPriorityQueue}.
23 | *
24 | *
Additionally, this interface strengthens {@link #comparator()}.
25 | */
26 |
27 | public interface INDIRECT_PRIORITY_QUEUE extends IndirectPriorityQueue {
28 |
29 | /** Returns the type-specific comparator associated with this queue.
30 | *
31 | * @apiNote Note that this specification strengthens the one given in {@link IndirectPriorityQueue}.
32 | *
33 | * @return the comparator associated with this queue.
34 | * @see IndirectPriorityQueue#comparator()
35 | */
36 | @Override
37 | KEY_COMPARATOR comparator();
38 | }
39 |
--------------------------------------------------------------------------------
/drv/Iterables.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | /** A class providing static methods and objects that do useful things with type-specific iterables.
21 | *
22 | * @see Iterable
23 | */
24 |
25 | public final class ITERABLES {
26 |
27 | private ITERABLES() {}
28 |
29 | /** Counts the number of elements returned by a type-specific iterable.
30 | *
31 | * @param iterable an iterable.
32 | * @return the number of elements returned by {@code iterable}.
33 | */
34 | public static KEY_GENERIC long size(final STD_KEY_ITERABLE KEY_GENERIC iterable) {
35 | long c = 0;
36 | for (@SuppressWarnings("unused") final KEY_GENERIC_TYPE dummy : iterable) c++;
37 | return c;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/drv/LinkedOpenCustomHashMap.drv:
--------------------------------------------------------------------------------
1 | OpenHashMap.drv
--------------------------------------------------------------------------------
/drv/LinkedOpenCustomHashSet.drv:
--------------------------------------------------------------------------------
1 | OpenHashSet.drv
--------------------------------------------------------------------------------
/drv/LinkedOpenHashMap.drv:
--------------------------------------------------------------------------------
1 | OpenHashMap.drv
--------------------------------------------------------------------------------
/drv/LinkedOpenHashSet.drv:
--------------------------------------------------------------------------------
1 | OpenHashSet.drv
--------------------------------------------------------------------------------
/drv/ListIterator.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import java.util.ListIterator;
21 |
22 | /** A type-specific bidirectional iterator that is also a {@link ListIterator}.
23 | *
24 | *
This interface merges the methods provided by a {@link ListIterator} and
25 | * a type-specific {@link it.unimi.dsi.fastutil.BidirectionalIterator}. Moreover, it provides
26 | * type-specific versions of {@link ListIterator#add(Object) add()}
27 | * and {@link ListIterator#set(Object) set()}.
28 | *
29 | * @see java.util.ListIterator
30 | * @see it.unimi.dsi.fastutil.BidirectionalIterator
31 | */
32 |
33 | public interface KEY_LIST_ITERATOR KEY_GENERIC extends KEY_BIDI_ITERATOR KEY_GENERIC, ListIterator {
34 |
35 | /**
36 | * Replaces the last element returned by {@link #next} or
37 | * {@link #previous} with the specified element (optional operation).
38 | * @param k the element used to replace the last element returned.
39 | *
40 | *
This default implementation just throws an {@link UnsupportedOperationException}.
41 | * @see ListIterator#set(Object)
42 | */
43 |
44 | #if KEYS_REFERENCE
45 | @Override
46 | #endif
47 | default void set(final KEY_GENERIC_TYPE k) { throw new UnsupportedOperationException(); }
48 |
49 | /**
50 | * Inserts the specified element into the list (optional operation).
51 | *
52 | *
This default implementation just throws an {@link UnsupportedOperationException}.
53 | * @param k the element to insert.
54 | * @see ListIterator#add(Object)
55 | */
56 |
57 | #if KEYS_REFERENCE
58 | @Override
59 | #endif
60 | default void add(final KEY_GENERIC_TYPE k) { throw new UnsupportedOperationException(); }
61 |
62 | /**
63 | * Removes from the underlying collection the last element returned
64 | * by this iterator (optional operation).
65 | *
66 | *
This default implementation just throws an {@link UnsupportedOperationException}.
67 | * @see ListIterator#remove()
68 | */
69 |
70 | @Override
71 | default void remove() { throw new UnsupportedOperationException(); }
72 |
73 |
74 |
75 | #if KEYS_PRIMITIVE
76 | /** {@inheritDoc}
77 | * @deprecated Please use the corresponding type-specific method instead. */
78 | @Deprecated
79 | @Override
80 | default void set(final KEY_CLASS k) { set(k.KEY_VALUE()); }
81 |
82 | /** {@inheritDoc}
83 | * @deprecated Please use the corresponding type-specific method instead. */
84 | @Deprecated
85 | @Override
86 | default void add(final KEY_CLASS k) { add(k.KEY_VALUE()); }
87 |
88 | /** {@inheritDoc}
89 | * @deprecated Please use the corresponding type-specific method instead. */
90 | @Deprecated
91 | @Override
92 | default KEY_GENERIC_CLASS next() { return KEY_BIDI_ITERATOR.super.next(); }
93 |
94 | /** {@inheritDoc}
95 | * @deprecated Please use the corresponding type-specific method instead. */
96 | @Deprecated
97 | @Override
98 | default KEY_GENERIC_CLASS previous() { return KEY_BIDI_ITERATOR.super.previous(); }
99 | #endif
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/drv/OpenCustomHashMap.drv:
--------------------------------------------------------------------------------
1 | OpenHashMap.drv
--------------------------------------------------------------------------------
/drv/OpenCustomHashSet.drv:
--------------------------------------------------------------------------------
1 | OpenHashSet.drv
--------------------------------------------------------------------------------
/drv/PriorityQueue.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003-2024 Paolo Boldi and Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import java.util.NoSuchElementException;
21 |
22 | import it.unimi.dsi.fastutil.PriorityQueue;
23 |
24 | /** A type-specific {@link PriorityQueue}; provides some additional methods that use polymorphism to avoid (un)boxing.
25 | *
26 | *
Additionally, this interface strengthens {@link #comparator()}.
27 | */
28 |
29 | public interface PRIORITY_QUEUE extends PriorityQueue {
30 |
31 | /** Enqueues a new element.
32 | * @see PriorityQueue#enqueue(Object)
33 | * @param x the element to enqueue.
34 | */
35 |
36 | void enqueue(KEY_GENERIC_TYPE x);
37 |
38 | /** Dequeues the {@linkplain #first() first} element from the queue.
39 | * @see #dequeue()
40 | * @return the dequeued element.
41 | * @throws NoSuchElementException if the queue is empty.
42 | */
43 |
44 | KEY_GENERIC_TYPE DEQUEUE();
45 |
46 | /** Returns the first element of the queue.
47 | * @see #first()
48 | * @return the first element.
49 | * @throws NoSuchElementException if the queue is empty.
50 | */
51 |
52 | KEY_GENERIC_TYPE FIRST();
53 |
54 | /** Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).
55 | *
This default implementation just throws an {@link UnsupportedOperationException}.
56 | * @see #last()
57 | * @return the last element.
58 | * @throws NoSuchElementException if the queue is empty.
59 | */
60 |
61 | default KEY_GENERIC_TYPE LAST() { throw new UnsupportedOperationException(); }
62 |
63 | /** Returns the comparator associated with this priority queue, or null if it uses its elements' natural ordering.
64 | *
65 | * @apiNote Note that this specification strengthens the one given in {@link PriorityQueue#comparator()}.
66 | * @see PriorityQueue#comparator()
67 | * @return the comparator associated with this priority queue.
68 | */
69 | @Override
70 | KEY_COMPARATOR comparator();
71 |
72 | /** {@inheritDoc}
73 | *
This default implementation delegates to the corresponding type-specific method.
74 | * @deprecated Please use the corresponding type-specific method instead. */
75 | @Deprecated
76 | @Override
77 | default void enqueue(final KEY_GENERIC_CLASS x) { enqueue(x.KEY_VALUE()); }
78 |
79 | /** {@inheritDoc}
80 | *
This default implementation delegates to the corresponding type-specific method.
81 | * @deprecated Please use the corresponding type-specific method instead. */
82 | @Deprecated
83 | @Override
84 | default KEY_GENERIC_CLASS dequeue() { return KEY2OBJ(DEQUEUE()); }
85 |
86 | /** {@inheritDoc}
87 | *
This default implementation delegates to the corresponding type-specific method.
88 | * @deprecated Please use the corresponding type-specific method instead. */
89 | @Deprecated
90 | @Override
91 | default KEY_GENERIC_CLASS first() { return KEY2OBJ(FIRST()); }
92 |
93 | /** {@inheritDoc}
94 | *
This default implementation delegates to the corresponding type-specific method.
95 | * @deprecated Please use the corresponding type-specific method instead. */
96 | @Deprecated
97 | @Override
98 | default KEY_GENERIC_CLASS last() { return KEY2OBJ(LAST()); }
99 | }
100 |
--------------------------------------------------------------------------------
/drv/SortedPair.drv:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | * Copyright (C) 2020-2024 Sebastiano Vigna
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 |
20 | package PACKAGE;
21 |
22 | /** A type-specific immutable {@link it.unimi.dsi.fastutil.SortedPair SortedPair}. */
23 |
24 | #if KEYS_PRIMITIVE
25 | public interface SORTED_PAIR extends PAIR, it.unimi.dsi.fastutil.SortedPair, java.io.Serializable {
26 | #else
27 | public interface SORTED_PAIR > extends PAIR , it.unimi.dsi.fastutil.SortedPair, java.io.Serializable {
28 | #endif
29 |
30 | /** Returns a new type-specific immutable {@link it.unimi.dsi.fastutil.SortedPair SortedPair} with given left and right value.
31 | *
32 | *
Note that if {@code left} and {@code right} are in the wrong order, they will be exchanged.
33 | *
34 | * @param left the left value.
35 | * @param right the right value.
36 | *
37 | * @implSpec This factory method delegates to the factory method of the corresponding immutable implementation.
38 | */
39 | #if KEYS_PRIMITIVE
40 | public static SORTED_PAIR of(final KEY_GENERIC_TYPE left, final KEY_GENERIC_TYPE right) {
41 | return IMMUTABLE_SORTED_PAIR.of(left, right);
42 | #else
43 | public static > SORTED_PAIR of(final KEY_GENERIC_TYPE left, final KEY_GENERIC_TYPE right) {
44 | return IMMUTABLE_SORTED_PAIR.of(left, right);
45 | #endif
46 | }
47 |
48 | #if KEYS_PRIMITIVE
49 | /**
50 | * Returns true if one of the two elements of this sorted pair is equal to a given element.
51 | *
52 | * @param e an element.
53 | * @return true if one of the two elements of this sorted pair is equal to {@code e}.
54 | * @see it.unimi.dsi.fastutil.SortedPair#contains(Object)
55 | */
56 | default boolean contains(final KEY_TYPE e) {
57 | return e == PAIR_LEFT() || e == PAIR_RIGHT();
58 | }
59 |
60 | /** {@inheritDoc}
61 | * @deprecated Please use the corresponding type-specific method instead.
62 | */
63 | @Deprecated
64 | @Override
65 | default boolean contains(final Object o) {
66 | if (o == null) return false;
67 | return contains(KEY_OBJ2TYPE(o));
68 | }
69 |
70 | #endif
71 |
72 |
73 | }
--------------------------------------------------------------------------------
/drv/Stack.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package PACKAGE;
19 |
20 | import it.unimi.dsi.fastutil.Stack;
21 |
22 | /** A type-specific {@link Stack}; provides some additional methods that use polymorphism to avoid (un)boxing. */
23 |
24 | public interface STACK KEY_GENERIC extends Stack {
25 |
26 | /** Pushes the given object on the stack.
27 | * @param k the object to push on the stack.
28 | * @see Stack#push(Object)
29 | */
30 | void push(KEY_TYPE k);
31 |
32 | /** Pops the top off the stack.
33 | *
34 | * @return the top of the stack.
35 | * @see Stack#pop()
36 | */
37 | KEY_TYPE POP();
38 |
39 | /** Peeks at the top of the stack (optional operation).
40 | * @return the top of the stack.
41 | * @see Stack#top()
42 | */
43 | KEY_TYPE TOP();
44 |
45 | /** Peeks at an element on the stack (optional operation).
46 | * @param i an index from the stop of the stack (0 represents the top).
47 | * @return the {@code i}-th element on the stack.
48 | * @see Stack#peek(int)
49 | */
50 | KEY_TYPE PEEK(int i);
51 |
52 | /** {@inheritDoc}
53 | *
This default implementation delegates to the corresponding type-specific method.
54 | * @deprecated Please use the corresponding type-specific method instead. */
55 | @Deprecated
56 | @Override
57 | default void push(KEY_GENERIC_CLASS o) {
58 | push(o.KEY_VALUE());
59 | }
60 |
61 | /** {@inheritDoc}
62 | *
This default implementation delegates to the corresponding type-specific method.
63 | * @deprecated Please use the corresponding type-specific method instead. */
64 | @Deprecated
65 | @Override
66 | default KEY_GENERIC_CLASS pop() {
67 | return KEY_CLASS.valueOf(POP());
68 | }
69 |
70 | /** {@inheritDoc}
71 | *
This default implementation delegates to the corresponding type-specific method.
72 | * @deprecated Please use the corresponding type-specific method instead. */
73 | @Deprecated
74 | @Override
75 | default KEY_GENERIC_CLASS top() {
76 | return KEY_CLASS.valueOf(TOP());
77 | }
78 |
79 | /** {@inheritDoc}
80 | *
This default implementation delegates to the corresponding type-specific method.
81 | * @deprecated Please use the corresponding type-specific method instead. */
82 | @Deprecated
83 | @Override
84 | default KEY_GENERIC_CLASS peek(final int i) {
85 | return KEY_CLASS.valueOf(PEEK(i));
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/drv/TextIO.drv:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2005-2024 Sebastiano Vigna
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package it.unimi.dsi.fastutil.io;
19 |
20 | import static it.unimi.dsi.fastutil.BigArrays.SEGMENT_MASK;
21 | import static it.unimi.dsi.fastutil.BigArrays.length;
22 | import static it.unimi.dsi.fastutil.BigArrays.start;
23 | import static it.unimi.dsi.fastutil.BigArrays.segment;
24 | import static it.unimi.dsi.fastutil.BigArrays.ensureOffsetLength;
25 |
26 | import java.io.*;
27 | import java.util.*;
28 | import it.unimi.dsi.fastutil.ints.*;
29 | import it.unimi.dsi.fastutil.longs.*;
30 | import it.unimi.dsi.fastutil.doubles.*;
31 | import it.unimi.dsi.fastutil.booleans.*;
32 | import it.unimi.dsi.fastutil.bytes.*;
33 | import it.unimi.dsi.fastutil.shorts.*;
34 | import it.unimi.dsi.fastutil.floats.*;
35 |
36 | /** Provides static methods to perform easily textual I/O.
37 | *
38 | *
This class fills a gap in the Java API: a natural operation on sequences
39 | * of primitive elements is to load or store them in textual form. This format
40 | * makes files humanly readable.
41 | *
42 | *
For each primitive type, this class provides methods that read elements
43 | * from a {@link BufferedReader} or from a filename (which will be opened
44 | * using a buffer of {@link #BUFFER_SIZE} bytes) into an array. Analogously,
45 | * there are methods that store the content of an array (fragment) or the
46 | * elements returned by an iterator to a {@link PrintStream} or to a given
47 | * filename.
48 | *
49 | *
Finally, there are useful wrapper methods that {@linkplain #asIntIterator(CharSequence)
50 | * exhibit a file as a type-specific iterator}.
51 | *
52 | *
Note that, contrarily to the binary case, there is no way to
53 | * {@linkplain BinIO#loadInts(CharSequence) load from a file without providing an array}. You can
54 | * easily work around the problem as follows:
55 | *