### Question:
SegmentationEngine { public List<Segment> process(List<Div> streamLayoutQueue) { double width = pageLayout.contentWidth(); if (streamLayoutQueue == null || streamLayoutQueue.isEmpty()) { return Collections.emptyList(); } LinkedList<Segment> res = new LinkedList<>(); LinkedList<Div> seq = new LinkedList<>(streamLayoutQueue); Segment segment = new Segment(width); while (!seq.isEmpty()) { Div div = seq.pop(); if (div.getPosition() == Position.Absolute) { continue; } boolean addSuccess = segment.tryAdd(div); if (!addSuccess && !segment.isEmpty()) { res.add(segment); segment = new Segment(width); seq.push(div); } } if (!segment.isEmpty()) { res.add(segment); } return res; } private  SegmentationEngine();  SegmentationEngine(PageLayout pageLayout); List<Segment> process(List<Div> streamLayoutQueue);  }### Answer:
@Test public void process() { SegmentationEngine sgnEngine = new SegmentationEngine(PageLayout.A4()); List<Div> list = new LinkedList<>(); list.add(new Div(50d, 25d).setFloat(AFloat.center)); Div div = new Div() .setClear(Clear.none) .setFloat(AFloat.left) .setWidth(38d) .setHeight(10d); list.add(div); List<Segment> segments = sgnEngine.process(list); Assertions.assertEquals(segments.size(), 2); list.add(new Div() .setClear(Clear.none) .setFloat(AFloat.left) .setWidth(90d) .setHeight(70d)); segments = sgnEngine.process(list); Assertions.assertEquals(segments.size(), 2); list.add(new Div() .setClear(Clear.none) .setFloat(AFloat.left) .setWidth(70d) .setHeight(70d)); segments = sgnEngine.process(list); Assertions.assertEquals(segments.size(), 3); }