Use std::deque for queues (#1112)

This commit is contained in:
vfjpl 2020-10-07 03:12:04 +02:00 committed by GitHub
parent 83959e5e23
commit b3d947d4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 8 deletions

View File

@ -763,7 +763,7 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
}
std::unordered_map<Position, Node*, PositionHasher> nodes;
std::priority_queue<std::pair<Node*, float>, std::vector<std::pair<Node*, float>>, LessNode> searchList;
std::priority_queue<std::pair<Node*, float>, std::deque<std::pair<Node*, float>>, LessNode> searchList;
Node *currentNode = new Node(startPos);
currentNode->pos = startPos;

View File

@ -74,7 +74,7 @@ void EventDispatcher::poll()
event->execute();
}
m_pollEventsSize = m_eventList.size();
loops++;
}
}
@ -116,4 +116,3 @@ EventPtr EventDispatcher::addEvent(const std::function<void()>& callback, bool p
m_eventList.push_back(event);
return event;
}

View File

@ -40,10 +40,10 @@ public:
ScheduledEventPtr cycleEvent(const std::function<void()>& callback, int delay);
private:
std::list<EventPtr> m_eventList;
std::deque<EventPtr> m_eventList;
int m_pollEventsSize;
stdext::boolean<false> m_disabled;
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
std::priority_queue<ScheduledEventPtr, std::deque<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
};
extern EventDispatcher g_dispatcher;

View File

@ -36,8 +36,8 @@ void microsleep(size_t us);
struct timer {
public:
timer() { restart(); }
float elapsed_seconds() { return (float)((stdext::micros() - m_start)/1000000.0); }
ticks_t elapsed_millis() { return (stdext::micros() - m_start)/1000; }
float elapsed_seconds() { return (stdext::micros() - m_start) / 1000000.f; }
ticks_t elapsed_millis() { return (stdext::micros() - m_start) / 1000; }
ticks_t elapsed_micros() { return stdext::micros() - m_start; }
void restart() { m_start = stdext::micros(); }
private:
@ -47,4 +47,3 @@ private:
}
#endif