201202203204205206207208209210211212213
contains(pb) ; } @Test public void ptrbuffer20() { PtrBuffer pb1 = make(5,5) ; contains(pb1, 2, 4, 6, 8, 10) ; PtrBuffer pb2 = make(0,5) ; contains(pb2) ; pb1.shiftRight(pb2) ; contains(pb1, 2, 4, 6, 8) ; contains(pb2, 10) ;
213214215216217218219220221222223224225
contains(pb2, 10) ; } @Test public void ptrbuffer21() { PtrBuffer pb1 = make(3,5) ; contains(pb1, 2, 4, 6) ; PtrBuffer pb2 = make(0,5) ; contains(pb2) ; pb1.shiftRight(pb2) ; contains(pb1, 2, 4) ; contains(pb2, 6) ;
225226227228229230231232233234235236237
contains(pb2, 6) ; } @Test public void ptrbuffer22() { PtrBuffer pb1 = make(3,5) ; contains(pb1, 2, 4, 6) ; PtrBuffer pb2 = make(2,5) ; contains(pb2, 2, 4) ; pb1.shiftRight(pb2) ; contains(pb1, 2, 4) ; contains(pb2, 6, 2, 4) ;
237238239240241242243244245246247248249
contains(pb2, 6, 2, 4) ; } @Test public void ptrbuffer24() { PtrBuffer pb1 = make(0,5) ; contains(pb1) ; PtrBuffer pb2 = make(5,5) ; contains(pb2, 2, 4, 6, 8, 10) ; pb1.shiftLeft(pb2) ; contains(pb1, 2) ; contains(pb2, 4, 6, 8, 10) ;
249250251252253254255256257258259260261
contains(pb2, 4, 6, 8, 10) ; } @Test public void ptrbuffer25() { PtrBuffer pb1 = make(0,5) ; contains(pb1) ; PtrBuffer pb2 = make(3,5) ; contains(pb2, 2, 4, 6) ; pb1.shiftLeft(pb2) ; contains(pb1, 2) ; contains(pb2, 4, 6) ;
261262263264265266267268269270271272273
contains(pb2, 4, 6) ; } @Test public void ptrbuffer26() { PtrBuffer pb1 = make(2,5) ; contains(pb1, 2, 4) ; PtrBuffer pb2 = make(3,5) ; contains(pb2, 2, 4, 6) ; pb1.shiftLeft(pb2) ; contains(pb1, 2, 4, 2) ; contains(pb2, 4, 6) ;
273274275276277278279280281282
contains(pb2, 4, 6) ; } @Test public void ptrbuffer27() { PtrBuffer pb1 = make(2,4) ; PtrBuffer pb2 = make(2,4) ; pb1.copyToTop(pb2) ; contains(pb2, 2,4,2,4) ; }
281282283284285286287288289290
contains(pb2, 2,4,2,4) ; } @Test public void ptrbuffer28() { PtrBuffer pb1 = make(0,5) ; PtrBuffer pb2 = make(2,4) ; pb1.copyToTop(pb2) ; contains(pb2, 2,4) ; }
289290291292293294295296297298
contains(pb2, 2,4) ; } @Test public void ptrbuffer29() { PtrBuffer pb1 = make(0,5) ; PtrBuffer pb2 = make(2,4) ; pb2.copyToTop(pb1) ; contains(pb1, 2,4) ; }
311312313314315316317318319320
// Make : 2,4,6,8, .. private static PtrBuffer make(int n) { return make(n,n) ; } private static PtrBuffer make(int n, int len) { ByteBuffer bb = ByteBuffer.allocate(4*len) ; PtrBuffer pb = new PtrBuffer(bb, 0) ; for ( int i = 0 ; i < n ; i++ ) pb.add(2+2*i) ; return pb ; }