#include <StrMod/LinearExtent.h>
Public Types | |
| typedef unsigned int | off_t |
| Type for expressing the offset. | |
| typedef unsigned int | length_t |
| Type for expressing the length. | |
Public Methods | |
| LinearExtent () | |
| A zero length extent starting at offset 0. | |
| LinearExtent (off_t offset, length_t length) | |
An extent starting at offset having length length. | |
| ~LinearExtent () | |
| Not meant to be inherited from, so not virtual. | |
| off_t | Offset () const |
| Retrieve offset. | |
| void | Offset (off_t new_off) |
| Set offset. | |
| length_t | Length () const |
| Retrieve length. | |
| void | Length (length_t new_length) |
| Set length. | |
| const LinearExtent | intersection (const LinearExtent &other) const |
| Given two extents, what is extent is common to both? | |
| const LinearExtent | SubExtent (const LinearExtent &extent) const |
| Translate a subextent into the underlying sequence's coordinate space. | |
| const LinearExtent & | SubExtent_eq (const LinearExtent &extent) |
| This function is to SubExtent() as += is to +. | |
STL Transforms | |
These functions translate the extent coordinate system of offset, length into the STL coordinate system of [begin, end). | |
| off_t | beginOffset () const |
| Offset of beginning of extent (for STL like algorithms). Same as Offset(). | |
| off_t | endOffset () const |
| Offset of end of extent (for STL like algorithms). Same as Offset() + Length() (undefined when Offset() + Length() > full_extent.Length(). | |
Extent as a Moveable Tape Measure | |
To understand what all these functions do, it's helpful to keep an image of the full contiguous sequence in mind, whith the LinearExtent acting as a sort of tape measure stretched along some part of the sequence. | |
| void | LengthenLeft (length_t by) |
| Lengthen an extent by lowering the offset and increasing the length by the same amount. | |
| void | LengthenRight (length_t by) |
| Lengthen an extent merely by adding to the length. | |
| void | ShortenLeft (length_t by) |
| Shorten an extent by increasing its offset and decreasing its length by the same amount. | |
| void | ShortenRight (length_t by) |
| Shorten an extent by simply decreasing its length. | |
| void | MoveRight (off_t by) |
| Add to the offset. | |
| void | MoveLeft (off_t by) |
| Subtract from the offset. | |
Static Public Attributes | |
| const off_t | OFFSET_MAX = UINT_MAX |
| const length_t | LENGTH_MAX = UINT_MAX |
| const LinearExtent | full_extent |
| A constant for an infinite length extent starting at offset 0. | |
This class sees such a subrange as beginning at an offset, and proceeding for some number of items.
The results of using objects of this class when Offset() + Length() > full_extent.Length() are undefined. To be safe, you should always use extents to refer to things who's absolute length is < UINT_MAX
Definition at line 63 of file LinearExtent.h.
|
|
Given two extents, what is extent is common to both? If there is no intersection, this will return an extent who's Offset() is undefined, and who's Length() is 0. This operator commutes. a.intersection(b) is guaranteed to yield the exact same results as b.intersection(a) in all cases except where a.Offset() + a.Length() > full_extent.Length(), or b.Offset() + b.Length() > full_extent.Length(). The results of intersection in the latter two cases are undefined. Definition at line 202 of file LinearExtent.h. |
|
|
A constant for an infinite length extent starting at offset 0. Not actually _infinite_, but of length UINT_MAX. |
1.3-rc1