Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_index_range.hh
| Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | public: | ||||
| * Returns true when the range contains a certain number, otherwise false. | * Returns true when the range contains a certain number, otherwise false. | ||||
| */ | */ | ||||
| constexpr bool contains(int64_t value) const | constexpr bool contains(int64_t value) const | ||||
| { | { | ||||
| return value >= start_ && value < start_ + size_; | return value >= start_ && value < start_ + size_; | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns true if the given range overlaps with the current one. | |||||
| */ | |||||
| constexpr bool overlaps(IndexRange other) const | |||||
| { | |||||
| return contains(other.start()) || other.contains(this->start()); | |||||
HooglyBoogly: Usually we try to be explicit about using `this->` before member functions just to be clearer. | |||||
| } | |||||
| /** | |||||
| * Returns a new range, that contains a sub-interval of the current one. | * Returns a new range, that contains a sub-interval of the current one. | ||||
| */ | */ | ||||
| constexpr IndexRange slice(int64_t start, int64_t size) const | constexpr IndexRange slice(int64_t start, int64_t size) const | ||||
| { | { | ||||
| BLI_assert(start >= 0); | BLI_assert(start >= 0); | ||||
| BLI_assert(size >= 0); | BLI_assert(size >= 0); | ||||
| int64_t new_start = start_ + start; | int64_t new_start = start_ + start; | ||||
| BLI_assert(new_start + size <= start_ + size_ || size == 0); | BLI_assert(new_start + size <= start_ + size_ || size == 0); | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||
Usually we try to be explicit about using this-> before member functions just to be clearer.