WPILibC++
2023.4.3-108-ge5452e3
Algorithm.h
Go to the documentation of this file.
1
// Copyright (c) FIRST and other WPILib contributors.
2
// Open Source Software; you can modify and/or share it under the terms of
3
// the WPILib BSD license file in the root directory of this project.
4
5
#pragma once
6
7
#include <algorithm>
8
#include <vector>
9
10
namespace
wpi
{
11
12
// Binary insertion into vector; std::log(n) efficiency.
13
template
<
typename
T>
14
typename
std::vector<T>::iterator
insert_sorted
(std::vector<T>& vec,
15
T
const
& item) {
16
return
vec.insert(std::upper_bound(vec.begin(), vec.end(), item), item);
17
}
18
}
// namespace wpi
wpi
Definition:
AprilTagFieldLayout.h:18
wpi::insert_sorted
std::vector< T >::iterator insert_sorted(std::vector< T > &vec, T const &item)
Definition:
Algorithm.h:14
wpi
Algorithm.h
Generated on Mon Jul 10 2023 17:03:00 for WPILibC++ by
1.9.4