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;
}

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 .
