public void testInvalidSize() { try { new RingBuffer( 0 ); Assert.fail(); } catch ( IllegalArgumentException e ) { // ignore } }
public void init( final StackedObjectPool<OrphanBlockContext> pool, final OrphanContext parent, final RenderBox contextBox, final int orphans ) { this.breakMarkerSeen = false; this.pool = pool; this.parent = parent; this.contextBox = contextBox; this.orphans = orphans; this.orphanOverride = contextBox.getCachedY(); this.orphanCount = 0; if ( orphans > 0 ) { if ( this.orphanSize == null ) { this.orphanSize = new RingBuffer<RenderNode>( orphans ); } else { this.orphanSize.resize( orphans ); } } }
public void init( final StackedObjectPool<WidowBlockContext> pool, final WidowContext parent, final RenderBox contextBox, final int widows ) { this.breakMarkerSeen = false; this.pool = pool; this.parent = parent; this.contextBox = contextBox; this.widows = widows; this.widowCount = 0; this.widowOverride = contextBox.getCachedY2(); this.widowOverrideWithKeepTogether = contextBox.getCachedY2(); if ( widows > 0 ) { if ( this.widowSize == null ) { this.widowSize = new RingBuffer<RenderNode>( widows ); } else { this.widowSize.resize( widows ); } } }
public void testAdding2() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); assertEquals( 30, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); }
public void testAdding() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); tc.add( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }
public void testReplaceFirst() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.replaceLastAdded( 10 ); assertEquals( 10, (int) tc.getFirstValue() ); assertEquals( 10, (int) tc.getLastValue() ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); tc.add( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }
public void testReplace() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); assertEquals( 30, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); tc.replaceLastAdded( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); tc.add( 50 ); assertEquals( 50, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }