Package it.unimi.di.prog2.e17
Class Histogram
java.lang.Object
it.unimi.di.prog2.e17.Histogram
A class to handle a list of rectangles and organize them as in histogram.
The rectangles are organized in decreasing height order, more specifically the iterator returns the rectangles in this order.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds aRectangle
to this histogram.void
changeBase
(Rectangle rectangle, int newBase) Changes the base of the given rectangleiterator()
Returns an iterator that produces the rectangles in this histogram in decreasing height order.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Histogram
public Histogram()Creates an empty histogram.
-
-
Method Details
-
add
Adds aRectangle
to this histogram.- Parameters:
rectangle
- the rectangle to add.
-
changeBase
Changes the base of the given rectangle- Parameters:
rectangle
- the rectangle.newBase
- the new base.- Throws:
NoSuchElementException
- if the rectangle is not in the histogram.
-
iterator
Returns an iterator that produces the rectangles in this histogram in decreasing height order.
-