mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Refactor C++ ScheduleCommand to use SmallSet (#5568)
Remove SetUtilities.h
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
#include "frc2/command/SetUtilities.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user