[commands] Refactor C++ ScheduleCommand to use SmallSet (#5568)

Remove SetUtilities.h
This commit is contained in:
Ryan Blue
2023-08-29 16:16:15 -04:00
committed by GitHub
parent 52297ffe29
commit 36d514eae7
5 changed files with 6 additions and 34 deletions

View File

@@ -11,7 +11,6 @@
#include "frc2/command/Command.h"
#include "frc2/command/CommandHelper.h"
#include "frc2/command/SetUtilities.h"
namespace frc2 {
/**

View File

@@ -6,11 +6,10 @@
#include <span>
#include <wpi/SmallVector.h>
#include <wpi/SmallSet.h>
#include "frc2/command/Command.h"
#include "frc2/command/CommandHelper.h"
#include "frc2/command/SetUtilities.h"
namespace frc2 {
/**
@@ -44,6 +43,6 @@ class ScheduleCommand : public CommandHelper<Command, ScheduleCommand> {
bool RunsWhenDisabled() const override;
private:
wpi::SmallVector<Command*, 4> m_toSchedule;
wpi::SmallSet<Command*, 4> m_toSchedule;
};
} // namespace frc2

View File

@@ -1,27 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <span>
#include <wpi/SmallVector.h>
namespace frc2 {
template <typename T>
void SetInsert(wpi::SmallVectorImpl<T*>& vector, std::span<T* const> toAdd) {
for (auto addCommand : toAdd) {
bool exists = false;
for (auto existingCommand : vector) {
if (addCommand == existingCommand) {
exists = true;
break;
}
}
if (!exists) {
vector.emplace_back(addCommand);
}
}
}
} // namespace frc2