diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-05-18 16:13:33 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-05-18 16:13:33 -0300 |
| commit | d28c1d4e8182ea54f5d68580944448d65c3f5d5e (patch) | |
| tree | 498887a213e5255131419985a7c9707d13190650 /src/vector.hh | |
| parent | 9b1af981f8d999df9e005213024be8e7fd7031ff (diff) | |
| download | game-d28c1d4e8182ea54f5d68580944448d65c3f5d5e.tar.gz game-d28c1d4e8182ea54f5d68580944448d65c3f5d5e.zip | |
implement `priority_queue`
Diffstat (limited to 'src/vector.hh')
| -rw-r--r-- | src/vector.hh | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/vector.hh b/src/vector.hh index 5c59d2c..044ffe1 100644 --- a/src/vector.hh +++ b/src/vector.hh @@ -39,7 +39,9 @@ struct vector{ } } - T *operator(int index){ + // TODO(fusion): Probably missing some inlined destructor? + + T *at(int index){ // TODO(fusion): This is probably not the best way to achieve this. while(index < this->start){ @@ -56,11 +58,7 @@ struct vector{ // TODO(fusion): Do we actually need to swap elements here? I'm // assuming some non-trivial structures that would invoke their // destructors when `this->entry` gets deleted just below. - { - T tmp = entry[new_index]; - entry[new_index] = this->entry[old_index]; - this->entry[old_index] = tmp; - } + std::swap(entry[new_index], this->entry[old_index]); } if(this->entry != NULL){ @@ -83,11 +81,7 @@ struct vector{ int new_index = old_index; // TODO(fusion): Same as above. - { - T tmp = entry[new_index]; - entry[new_index] = this->entry[old_index]; - this->entry[old_index] = tmp; - } + std::swap(entry[new_index], this->entry[old_index]); } if(this->entry != NULL){ |
