#pragma once namespace nall { template auto vector::fill(const T& value) -> void { for(uint64_t n : range(size())) _pool[n] = value; } template auto vector::sort(const function& comparator) -> void { nall::sort(_pool, _size, comparator); } template auto vector::reverse() -> void { vector reversed; for(uint64_t n : range(size())) reversed.prepend(_pool[n]); operator=(move(reversed)); } template auto vector::find(const function& comparator) -> maybe { for(uint64_t n : range(size())) if(comparator(_pool[n])) return n; return nothing; } template auto vector::find(const T& value) const -> maybe { for(uint64_t n : range(size())) if(_pool[n] == value) return n; return nothing; } template auto vector::findSorted(const T& value) const -> maybe { int64_t l = 0, r = size() - 1; while(l <= r) { int64_t m = l + (r - l >> 1); if(value == _pool[m]) return m; value < _pool[m] ? r = m - 1 : l = m + 1; } return nothing; } template auto vector::foreach(const function& callback) -> void { for(uint64_t n : range(size())) callback(_pool[n]); } template auto vector::foreach(const function& callback) -> void { for(uint64_t n : range(size())) callback(n, _pool[n]); } }