Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_vector.hh
| Show First 20 Lines • Show All 470 Lines • ▼ Show 20 Lines | public: | ||||
| void append_non_duplicates(const T &value) | void append_non_duplicates(const T &value) | ||||
| { | { | ||||
| if (!this->contains(value)) { | if (!this->contains(value)) { | ||||
| this->append(value); | this->append(value); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Same as append_non_duplicates, but also return index of first equal element or new element. | |||||
| */ | |||||
| int64_t append_non_duplicates_and_get_index(const T &value) | |||||
| { | |||||
| if (const int64_t index = this->first_index_of_try(value); index != -1) { | |||||
| return index; | |||||
| } | |||||
| else { | |||||
| return this->append_and_get_index_as(value); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Append the value and assume that vector has enough memory reserved. This invokes undefined | * Append the value and assume that vector has enough memory reserved. This invokes undefined | ||||
| * behavior when not enough capacity has been reserved beforehand. Only use this in performance | * behavior when not enough capacity has been reserved beforehand. Only use this in performance | ||||
| * critical code. | * critical code. | ||||
| */ | */ | ||||
| void append_unchecked(const T &value) | void append_unchecked(const T &value) | ||||
| { | { | ||||
| this->append_unchecked_as(value); | this->append_unchecked_as(value); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 530 Lines • Show Last 20 Lines | |||||