Java Code Examples for java.nio.LongBuffer#asReadOnlyBuffer()
The following examples show how to use
java.nio.LongBuffer#asReadOnlyBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 6 votes |
@Test public void roundtrip() throws Exception { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (ObjectOutputStream oo = new ObjectOutputStream(bos)) { bc.writeExternal(oo); } MappeableContainer bc2 = new MappeableBitmapContainer(); final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); bc2.readExternal(new ObjectInputStream(bis)); assertEquals(64, bc2.getCardinality()); for (int i = 0; i < 64; i++) { assertTrue(bc2.contains((char) i)); } }
Example 2
Source File: BufferTest.java From j2objc with Apache License 2.0 | 5 votes |
private void testLongBufferByteOrder(LongBuffer b, ByteOrder bo) throws Exception { assertEquals(bo, b.order()); assertEquals(bo, b.duplicate().order()); assertEquals(bo, b.slice().order()); b = b.asReadOnlyBuffer(); assertEquals(bo, b.order()); assertEquals(bo, b.duplicate().order()); assertEquals(bo, b.slice().order()); }
Example 3
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void numberOfRuns2() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~8L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); assertEquals(2, bc.numberOfRuns()); }
Example 4
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void select() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); assertEquals(100, bc.select(100)); }
Example 5
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void andNotArray() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableContainer ac = new MappeableArrayContainer(); ac = ac.add(32, 64); bc = bc.andNot(ac); assertEquals(32, bc.getCardinality()); for (char i = 0; i < 32; i++) { assertTrue(bc.contains(i)); } }
Example 6
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void andNotBitmap() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableContainer bc2 = new MappeableBitmapContainer(); bc2 = bc2.add(32, 64); bc = bc.andNot(bc2); assertEquals(32, bc.getCardinality()); for (char i = 0; i < 32; i++) { assertTrue(bc.contains(i)); } }
Example 7
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void intersectsBitmap() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); LongBuffer buffer2 = LongBuffer.allocate(MAX_CAPACITY / 64); buffer2.put(~1L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableContainer bc2 = new MappeableBitmapContainer(buffer2.asReadOnlyBuffer(), 64); assertTrue(bc.intersects(bc2)); }
Example 8
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void xorArray() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableContainer ac = newArrayContainer(5, 15); bc = bc.xor(ac); assertEquals(54, bc.getCardinality()); for (char i = 0; i < 5; i++) { assertTrue(bc.contains(i)); } for (char i = 15; i < 64; i++) { assertTrue(bc.contains(i)); } }
Example 9
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void xorBitmap() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableContainer bc2 = new MappeableBitmapContainer(); bc2 = bc2.add(10, 64); bc = bc.xor(bc2); assertEquals(10, bc.getCardinality()); for (char i = 0; i < 10; i++) { assertTrue(bc.contains(i)); } }
Example 10
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void xorBitmap2() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); for (int i = 0; i < 128; i++) { buffer.put(~0L); } MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 8192); MappeableContainer bc2 = new MappeableBitmapContainer(); bc2 = bc2.add(5000, 8192); bc = bc.xor(bc2); assertEquals(5000, bc.getCardinality()); for (char i = 0; i < 5000; i++) { assertTrue(bc.contains(i)); } }
Example 11
Source File: TestMappeableBitmapContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void foreach() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); bc.forEach((char) 0, new IntConsumer() { int expected = 0; @Override public void accept(int value) { assertEquals(value, expected++); } }); }
Example 12
Source File: TestMappeableRunContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Test public void constructorBitmap() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableBitmapContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); MappeableRunContainer rc = new MappeableRunContainer(bc, 1); assertEquals(64, rc.getCardinality()); for (int i = 0; i < 64; i++) { assertTrue(rc.contains((char) i)); } }