Skip to content

Commit

Permalink
Long-keyed maps; start on object stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Nov 14, 2023
1 parent 5ee4359 commit dfe8d6a
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 32 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/github/tommyettinger/ds/LongFloatMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.github.tommyettinger.function.LongToFloatFunction;
import com.github.tommyettinger.ds.support.util.FloatIterator;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.AbstractSet;
import java.util.Arrays;
Expand Down Expand Up @@ -824,7 +825,7 @@ public void truncate (int newSize) {
* @return an {@link Iterator} over {@link Entry} key-value pairs; remove is supported.
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down Expand Up @@ -1138,7 +1139,7 @@ public EntryIterator (LongFloatMap map) {
}

@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return this;
}

Expand Down Expand Up @@ -1182,7 +1183,7 @@ public Entries (LongFloatMap map) {
* @return an iterator over the elements contained in this collection
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return iter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.github.tommyettinger.ds.support.sort.LongComparators;

import com.github.tommyettinger.ds.support.util.LongIterator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -606,7 +607,7 @@ public Entries entrySet () {
* @return an {@link Iterator} over key-value pairs as {@link Map.Entry} values
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/github/tommyettinger/ds/LongIntMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.github.tommyettinger.function.LongIntBiConsumer;
import com.github.tommyettinger.function.LongIntToIntBiFunction;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.AbstractSet;
import java.util.Arrays;
Expand Down Expand Up @@ -781,7 +782,7 @@ public void truncate (int newSize) {
* @return an {@link Iterator} over {@link Entry} key-value pairs; remove is supported.
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down Expand Up @@ -1095,7 +1096,7 @@ public EntryIterator (LongIntMap map) {
}

@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return this;
}

Expand Down Expand Up @@ -1139,7 +1140,7 @@ public Entries (LongIntMap map) {
* @return an iterator over the elements contained in this collection
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return iter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.github.tommyettinger.ds.support.sort.LongComparators;

import com.github.tommyettinger.ds.support.util.LongIterator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -607,7 +608,7 @@ public Entries entrySet () {
* @return an {@link Iterator} over key-value pairs as {@link Map.Entry} values
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/github/tommyettinger/ds/LongLongMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.tommyettinger.ds.support.util.LongIterator;
import com.github.tommyettinger.function.LongLongBiConsumer;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.AbstractSet;
import java.util.Arrays;
Expand Down Expand Up @@ -781,7 +782,7 @@ public void truncate (int newSize) {
* @return an {@link Iterator} over {@link Entry} key-value pairs; remove is supported.
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down Expand Up @@ -1094,7 +1095,7 @@ public EntryIterator (LongLongMap map) {
}

@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return this;
}

Expand Down Expand Up @@ -1138,7 +1139,7 @@ public Entries (LongLongMap map) {
* @return an iterator over the elements contained in this collection
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return iter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.tommyettinger.ds.support.sort.LongComparators;

import com.github.tommyettinger.ds.support.util.LongIterator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -604,7 +605,7 @@ public Entries entrySet () {
* @return an {@link Iterator} over key-value pairs as {@link Map.Entry} values
*/
@Override
public Iterator<Entry> iterator () {
public @NonNull EntryIterator iterator () {
return entrySet().iterator();
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/github/tommyettinger/ds/LongObjectMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.github.tommyettinger.function.LongObjToObjBiFunction;

import com.github.tommyettinger.function.LongToObjFunction;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.AbstractCollection;
import java.util.AbstractSet;
Expand Down Expand Up @@ -782,7 +783,7 @@ public void truncate (int newSize) {
* @return an {@link Iterator} over {@link Entry} key-value pairs; remove is supported.
*/
@Override
public Iterator<Entry<V>> iterator () {
public @NonNull EntryIterator<V> iterator () {
return entrySet().iterator();
}

Expand Down Expand Up @@ -1100,7 +1101,7 @@ public EntryIterator (LongObjectMap<V> map) {
}

@Override
public Iterator<Entry<V>> iterator () {
public @NonNull EntryIterator<V> iterator () {
return this;
}

Expand Down Expand Up @@ -1144,7 +1145,7 @@ public Entries (LongObjectMap<V> map) {
* @return an iterator over the elements contained in this collection
*/
@Override
public Iterator<Entry<V>> iterator () {
public @NonNull EntryIterator<V> iterator () {
return iter;
}

Expand Down Expand Up @@ -1253,7 +1254,7 @@ public void clear () {
* @return an iterator over the elements contained in this collection
*/
@Override
public Iterator<V> iterator () {
public @NonNull ValueIterator<V> iterator () {
return iter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.tommyettinger.ds.support.sort.LongComparators;

import com.github.tommyettinger.ds.support.util.LongIterator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Comparator;
Expand Down Expand Up @@ -587,7 +588,7 @@ public Entries<V> entrySet () {
* @return an {@link Iterator} over key-value pairs as {@link Map.Entry} values
*/
@Override
public Iterator<Entry<V>> iterator () {
public @NonNull EntryIterator<V> iterator () {
return entrySet().iterator();
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/github/tommyettinger/ds/NumberedSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.github.tommyettinger.ds;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Iterator;
Expand Down Expand Up @@ -343,7 +344,7 @@ public boolean addAll (int insertionIndex, T[] array, int offset, int count) {
}

@Override
public boolean retainAll (Collection<?> c) {
public boolean retainAll (@NonNull Collection<?> c) {
boolean modified = false;
Iterator<T> it = iterator();
while (it.hasNext()) {
Expand All @@ -360,7 +361,7 @@ public boolean retainAll (Collection<?> c) {
}

@Override
public boolean removeAll (Collection<?> c) {
public boolean removeAll (@NonNull Collection<?> c) {
boolean modified = false;
Iterator<?> it = iterator();
while (it.hasNext()) {
Expand Down Expand Up @@ -518,7 +519,7 @@ public void truncate (int newSize) {
* @return a ListIterator, or more specifically a {@link NumberedSetIterator} over this set
*/
@Override
public NumberedSetIterator<T> iterator () {
public @NonNull NumberedSetIterator<T> iterator () {
if (iterator1 == null || iterator2 == null) {
iterator1 = new NumberedSetIterator<>(this);
iterator2 = new NumberedSetIterator<>(this);
Expand Down Expand Up @@ -601,12 +602,12 @@ public void removeRange (int start, int end) {
}

@Override
public Object[] toArray () {
public Object @NonNull [] toArray () {
return map.keySet().toArray();
}

@Override
public <T1> T1[] toArray (T1[] a) {
public <T1> T1 @NonNull [] toArray (T1 @NonNull [] a) {
return map.keySet().toArray(a);
}

Expand Down Expand Up @@ -902,7 +903,7 @@ public void reset (int index) {
* @return a ListIterator; really this same NumberedSetIterator.
*/
@Override
public NumberedSetIterator<T> iterator () {
public @NonNull NumberedSetIterator<T> iterator () {
return this;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/github/tommyettinger/ds/ObjectDeque.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.github.tommyettinger.ds;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -815,7 +816,7 @@ public int size () {
* type} is {@code Object}, containing all of the elements in this collection
*/
@Override
public Object[] toArray () {
public Object @NonNull [] toArray () {
Object[] next = new Object[size];
if (head < tail) {
System.arraycopy(values, head, next, 0, tail - head);
Expand Down Expand Up @@ -854,7 +855,7 @@ public Object[] toArray () {
* @throws NullPointerException if the specified array is null
*/
@Override
public <E> E[] toArray (E[] a) {
public <E> E @NonNull [] toArray (E[] a) {
int oldSize = size;
if (a.length < oldSize) {
a = Arrays.copyOf(a, oldSize);
Expand Down Expand Up @@ -1260,7 +1261,7 @@ public void clear () {
* iteration, use {@link ObjectDequeIterator#ObjectDequeIterator(ObjectDeque)}.
*/
@Override
public ObjectDequeIterator<T> iterator () {
public @NonNull ObjectDequeIterator<T> iterator () {
if (iterator1 == null || iterator2 == null) {
iterator1 = new ObjectDequeIterator<>(this);
iterator2 = new ObjectDequeIterator<>(this);
Expand Down Expand Up @@ -1288,7 +1289,7 @@ public ObjectDequeIterator<T> iterator () {
* @return an iterator over the elements in this deque in reverse sequence
*/
@Override
public ObjectDequeIterator<T> descendingIterator () {
public @NonNull ObjectDequeIterator<T> descendingIterator () {
if (descendingIterator1 == null || descendingIterator2 == null) {
descendingIterator1 = new ObjectDequeIterator<>(this, true);
descendingIterator2 = new ObjectDequeIterator<>(this, true);
Expand Down Expand Up @@ -1750,7 +1751,7 @@ public void reset (int index) {
* @return a ListIterator; really this same ObjectDequeIterator.
*/
@Override
public ObjectDequeIterator<T> iterator () {
public @NonNull ObjectDequeIterator<T> iterator () {
return this;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/github/tommyettinger/ds/ObjectList.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.github.tommyettinger.ds.support.sort.ObjectComparators;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -491,7 +492,7 @@ public StringBuilder builderAppend (StringBuilder builder, String separator) {
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
public ObjectListIterator<T> listIterator (int index) {
public @NonNull ObjectListIterator<T> listIterator (int index) {
if (iterator1 == null || iterator2 == null) {
iterator1 = new ObjectListIterator<>(this, index);
iterator2 = new ObjectListIterator<>(this, index);
Expand All @@ -517,7 +518,7 @@ public ObjectListIterator<T> listIterator (int index) {
* @see #listIterator(int)
*/
@Override
public ObjectListIterator<T> listIterator () {
public @NonNull ObjectListIterator<T> listIterator () {
if (iterator1 == null || iterator2 == null) {
iterator1 = new ObjectListIterator<>(this);
iterator2 = new ObjectListIterator<>(this);
Expand All @@ -543,7 +544,7 @@ public ObjectListIterator<T> listIterator () {
* @return an iterator over the elements in this list in proper sequence
*/
@Override
public ObjectListIterator<T> iterator () {
public @NonNull ObjectListIterator<T> iterator () {
if (iterator1 == null || iterator2 == null) {
iterator1 = new ObjectListIterator<>(this);
iterator2 = new ObjectListIterator<>(this);
Expand Down Expand Up @@ -767,7 +768,7 @@ public void reset (int index) {
* @return a ListIterator; really this same ObjectListIterator.
*/
@Override
public ObjectListIterator<T> iterator () {
public @NonNull ObjectListIterator<T> iterator () {
return this;
}
}
Expand Down

0 comments on commit dfe8d6a

Please sign in to comment.