List < Integer > segmentSizes ( ) { if ( head == null ) return Collections . emptyList ( ) ; List < Integer > result = new ArrayList <> ( ) ; result . add ( head . limit - head . pos ) ; for ( Segment s = head . next ; s != head ; s = s . next ) { result . add ( s . limit - s . pos ) ; } return result ; }
For testing . This returns the sizes of the segments in this buffer .