mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Removed unused includes and replaced Ultrasonic's std::set with std::vector (#767)
This commit is contained in:
committed by
Peter Johnson
parent
5c659fdcdf
commit
a00b2449db
@@ -22,7 +22,7 @@ using namespace frc;
|
||||
// Automatic round robin mode
|
||||
std::atomic<bool> Ultrasonic::m_automaticEnabled{false};
|
||||
|
||||
std::set<Ultrasonic*> Ultrasonic::m_sensors;
|
||||
std::vector<Ultrasonic*> Ultrasonic::m_sensors;
|
||||
std::thread Ultrasonic::m_thread;
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ void Ultrasonic::Initialize() {
|
||||
bool originalMode = m_automaticEnabled;
|
||||
SetAutomaticMode(false); // Kill task when adding a new sensor
|
||||
// Link this instance on the list
|
||||
m_sensors.insert(this);
|
||||
m_sensors.emplace_back(this);
|
||||
|
||||
m_counter.SetMaxPeriod(1.0);
|
||||
m_counter.SetSemiPeriodMode(true);
|
||||
@@ -172,7 +172,8 @@ Ultrasonic::~Ultrasonic() {
|
||||
SetAutomaticMode(false);
|
||||
|
||||
// No synchronization needed because the background task is stopped.
|
||||
m_sensors.erase(this);
|
||||
m_sensors.erase(std::remove(m_sensors.begin(), m_sensors.end(), this),
|
||||
m_sensors.end());
|
||||
|
||||
if (!m_sensors.empty() && wasAutomaticMode) {
|
||||
SetAutomaticMode(true);
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "Counter.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
@@ -90,7 +90,7 @@ class Ultrasonic : public SensorBase,
|
||||
static std::thread m_thread;
|
||||
|
||||
// Ultrasonic sensors
|
||||
static std::set<Ultrasonic*> m_sensors;
|
||||
static std::vector<Ultrasonic*> m_sensors;
|
||||
|
||||
// Automatic round-robin mode
|
||||
static std::atomic<bool> m_automaticEnabled;
|
||||
|
||||
Reference in New Issue
Block a user