Skip to content

Commit

Permalink
[Java] Allow access to primitive key value in iterator of object cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jan 8, 2018
1 parent 9eb7e57 commit 413b148
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions agrona/src/main/java/org/agrona/collections/Int2ObjectCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public KeySet keySet()
/**
* {@inheritDoc}
*/
public Collection<V> values()
public ValueCollection<V> values()
{
if (null == valueCollection)
{
Expand Down Expand Up @@ -575,7 +575,7 @@ public boolean equals(final Object o)
// Internal Sets and Collections
///////////////////////////////////////////////////////////////////////////////////////////////

public class KeySet extends AbstractSet<Integer>
public final class KeySet extends AbstractSet<Integer>
{
private final KeyIterator iterator = new KeyIterator();

Expand Down Expand Up @@ -612,7 +612,7 @@ public void clear()
}
}

class ValueCollection<T> extends AbstractCollection<T>
public final class ValueCollection<T> extends AbstractCollection<T>
{
private final ValueIterator<T> iterator = new ValueIterator<>();

Expand All @@ -639,7 +639,7 @@ public void clear()
}
}

class EntrySet<T> extends AbstractSet<Entry<Integer, T>>
public final class EntrySet<T> extends AbstractSet<Entry<Integer, T>>
{
private final EntryIterator<T> iterator = new EntryIterator<>();

Expand Down Expand Up @@ -714,7 +714,7 @@ void reset()
}
}

public class ValueIterator<T> extends AbstractIterator<T>
public final class ValueIterator<T> extends AbstractIterator<T>
{
@SuppressWarnings("unchecked")
public T next()
Expand All @@ -725,7 +725,7 @@ public T next()
}
}

public class KeyIterator extends AbstractIterator<Integer>
public final class KeyIterator extends AbstractIterator<Integer>
{
public Integer next()
{
Expand All @@ -741,7 +741,7 @@ public int nextInt()
}

@SuppressWarnings("unchecked")
public class EntryIterator<T>
public final class EntryIterator<T>
extends AbstractIterator<Entry<Integer, T>>
implements Entry<Integer, T>
{
Expand All @@ -753,6 +753,11 @@ public Entry<Integer, T> next()
}

public Integer getKey()
{
return getIntKey();
}

public Integer getIntKey()
{
return keys[position()];
}
Expand Down

0 comments on commit 413b148

Please sign in to comment.