wavelength 1.0.0
Loading...
Searching...
No Matches
vectorutil.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
18template <class T>
19void VectorRemove(std::vector<T> &vector, const T &value) {
20 for (auto it = vector.begin(); it != vector.end(); ++it) {
21 if (*it == value) {
22 vector.erase(it);
23 return;
24 }
25 }
26}
27
39template <class T>
40T *VectorFind(std::vector<T> &vector, const T &value) {
41 for (auto &element : vector) {
42 if (element == value) {
43 return &element;
44 }
45 }
46 return nullptr;
47}
T * VectorFind(std::vector< T > &vector, const T &value)
Find the first element of a vector equal to a value.
Definition vectorutil.h:40
void VectorRemove(std::vector< T > &vector, const T &value)
Remove the first element of a vector equal to a value.
Definition vectorutil.h:19