WPILibC++ 2023.4.3
SetUtilities.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 <span>
8
9#include <wpi/SmallVector.h>
10
11namespace frc2 {
12template <typename T>
13void SetInsert(wpi::SmallVectorImpl<T*>& vector, std::span<T* const> toAdd) {
14 for (auto addCommand : toAdd) {
15 bool exists = false;
16 for (auto existingCommand : vector) {
17 if (addCommand == existingCommand) {
18 exists = true;
19 break;
20 }
21 }
22 if (!exists) {
23 vector.emplace_back(addCommand);
24 }
25 }
26}
27} // namespace frc2
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:557
Definition: InstantCommand.h:14
void SetInsert(wpi::SmallVectorImpl< T * > &vector, std::span< T *const > toAdd)
Definition: SetUtilities.h:13