Skip to content

Commit

Permalink
Move more classes out of primitive collections module
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Koval committed May 8, 2018
1 parent 84cac96 commit 0cac275
Show file tree
Hide file tree
Showing 23 changed files with 14 additions and 389 deletions.
9 changes: 6 additions & 3 deletions community/collections/pom.xml
Expand Up @@ -72,11 +72,14 @@ the relevant Commercial Agreement.
<artifactId>neo4j-common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.collection.primitive;

import org.eclipse.collections.api.iterator.LongIterator;

import java.util.Arrays;

import static org.neo4j.collection.primitive.PrimitiveLongCollections.EMPTY_LONG_ARRAY;
Expand Down Expand Up @@ -225,23 +223,6 @@ else if ( left[l] < right[r] )
return difference;
}

/**
* Copy PrimitiveLongCollection into new long array
* @param collection the collection to copy
* @return the new long array
*/
public static long[] of( PrimitiveLongCollection collection )
{
int i = 0;
long[] result = new long[collection.size()];
final LongIterator iterator = collection.longIterator();
while ( iterator.hasNext() )
{
result[i++] = iterator.next();
}
return result;
}

/**
* Compute the number of unique values in two sorted long array sets
* @param left a sorted array set
Expand Down
Expand Up @@ -31,7 +31,7 @@
* Queue capacity should always be power of two to be able to use
* '&' mask operation with {@link #values} length.
*/
public class PrimitiveLongArrayQueue implements PrimitiveLongCollection
public class PrimitiveLongArrayQueue
{
private static final int DEFAULT_CAPACITY = 16;
private long[] values;
Expand All @@ -49,31 +49,26 @@ public PrimitiveLongArrayQueue()
initValues( capacity );
}

@Override
public boolean isEmpty()
{
return head == tail;
}

@Override
public void clear()
{
initValues( DEFAULT_CAPACITY );
}

@Override
public int size()
{
return (tail - head) & (values.length - 1);
}

@Override
public void close()
{
values = PrimitiveLongCollections.EMPTY_LONG_ARRAY;
}

@Override
public LongIterator longIterator()
{
return new PrimitiveLongArrayQueueIterator();
Expand Down
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.collection.primitive;

import org.eclipse.collections.api.iterator.LongIterator;
import org.junit.Assert;
import org.junit.Test;

import java.util.NoSuchElementException;
Expand Down Expand Up @@ -172,7 +173,7 @@ public void tailBeforeHeadCorrectIteration()
for ( int j = 10; j < 24; j++ )
{
assertTrue( iterator.hasNext() );
assertEquals( j, iterator.next() );
Assert.assertEquals( j, iterator.next() );
}
assertFalse( iterator.hasNext() );
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.collections.api.iterator.LongIterator;
import org.eclipse.collections.api.set.primitive.LongSet;
import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet;
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
Expand Down Expand Up @@ -190,10 +191,10 @@ protected boolean fetchNext()
// WHEN/THEN
assertTrue( iterator.hasNext() );
assertTrue( iterator.hasNext() );
assertEquals( 1L, iterator.next() );
Assert.assertEquals( 1L, iterator.next() );
assertTrue( iterator.hasNext() );
assertTrue( iterator.hasNext() );
assertEquals( 0L, iterator.next() );
Assert.assertEquals( 0L, iterator.next() );
assertFalse( iterator.hasNext() );
assertFalse( iterator.hasNext() );
assertEquals( -1L, count.get() );
Expand All @@ -207,7 +208,7 @@ public void convertJavaCollectionToSetOfPrimitives()
assertTrue( longSet.contains( 1L ) );
assertTrue( longSet.contains( 4L ) );
assertTrue( longSet.contains( 7L ) );
assertEquals( 3, longSet.size() );
Assert.assertEquals( 3, longSet.size() );
}

@Test
Expand Down Expand Up @@ -235,7 +236,7 @@ private void assertNoMoreItems( LongIterator iterator )
private void assertNextEquals( long expected, LongIterator iterator )
{
assertTrue( iterator + " should have had more items", iterator.hasNext() );
assertEquals( expected, iterator.next() );
Assert.assertEquals( expected, iterator.next() );
}

private void assertItems( LongIterator iterator, long... expectedItems )
Expand Down
4 changes: 0 additions & 4 deletions community/primitive-collections/pom.xml
Expand Up @@ -64,10 +64,6 @@ the relevant Commercial Agreement.
<artifactId>neo4j-resource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0cac275

Please sign in to comment.