WPILibC++
2020.3.2
SetUtilities.h
1
/*----------------------------------------------------------------------------*/
2
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3
/* Open Source Software - may be modified and shared by FRC teams. The code */
4
/* must be accompanied by the FIRST BSD license file in the root directory of */
5
/* the project. */
6
/*----------------------------------------------------------------------------*/
7
8
#pragma once
9
10
#include <wpi/ArrayRef.h>
11
#include <wpi/SmallVector.h>
12
13
namespace
frc2 {
14
template
<
typename
T>
15
void
SetInsert(
wpi::SmallVectorImpl<T*>
& vector,
wpi::ArrayRef<T*>
toAdd) {
16
for
(
auto
addCommand : toAdd) {
17
bool
exists =
false
;
18
for
(
auto
existingCommand : vector) {
19
if
(addCommand == existingCommand) {
20
exists =
true
;
21
break
;
22
}
23
}
24
if
(!exists) {
25
vector.emplace_back(addCommand);
26
}
27
}
28
}
29
}
// namespace frc2
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:
ArrayRef.h:42
wpi::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:
sha1.h:31
wpilibNewCommands
src
main
native
include
frc2
command
SetUtilities.h
Generated on Fri Feb 21 2020 08:50:36 for WPILibC++ by
1.8.16