Two Colored Range
Two colored range - range that is filled completely with subranges of one of two colors. It provides features for painting and requesting subranges.
A newly created colored range looks like this (assuming range is 0..12 and defaultColor is c1):
0 4 8 12
[ c1 ]
Example of colored range:
0 4 8 12
[ c2 ][ c1 ][ c2 ]
All mutating and requesting functions are supposed to make smart subranges joining and splitting. For example, having colored range:
0 4 8 12
[ c2 ][ c1 ]
and applying color 2 to subrange 5..8 should change colored range to:
0 4 8 12
[ c2 ][ c1 ]
and a consequent call of getSubrangeOfColor(c2, 2, 4..10) should return 4..5.
Parameters
the type of colored range bounds.
the type of length between bounds. Usually it is the same as BoundType, but it may be different, for example: BoundType = LocalDate, LengthType = DatePeriod.
the type of range colors.
Inheritors
Properties
the default color, a colored range is supposed to be fully colored with it right after constructor call.
the length of colored range.
the math used for calculating lengths and distances of subranges.
the second color.
a regular range marking bounds of colored range.
the factory for ranges, it is used for custom ranges type. For example IntRange is more convenient than ClosedRange<BoundType> for equality checks outside the interface or class.
the minimal non-zero length of a subrange and distance between two neighbour subranges. Usually it has a value of 1 for integer types of BoundType.
Functions
getSubrangeOfColor called with maxLength = step and limitByRange = range.
getSubrangeOfColor called with limitByRange = range.
getSubrangeOfColor called with maxLength = step.
Performs a search for a subrange with color color limited by limitByRange. If a subrange with length >= maxLength was found then returns a subrange from foundSubrange.start to foundSubrange.start + maxLength (involving math and rangeFactory). Otherwise returns first non-empty subrange with color color inside limitByRange or null.
Returns list of subranges colored with color.
Returns list of subranges colored with defaultColor.
Returns list of subranges colored with otherColor.
Iterator limited by limitByRange.