mirror of
https://github.com/koloideal/SortLab.git
synced 2026-06-10 10:25:30 +03:00
skelet
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "Array.hpp"
|
||||
#include "Sorter.hpp"
|
||||
#include "UI.hpp"
|
||||
#include "OperationsHistory.hpp"
|
||||
|
||||
class App {
|
||||
public:
|
||||
@@ -15,6 +16,7 @@ private:
|
||||
void handleEvents();
|
||||
void update(float dt);
|
||||
void render();
|
||||
void renderHistogram();
|
||||
void switchSorter(std::unique_ptr<Sorter> newSorter);
|
||||
void generateBeepSound();
|
||||
void playBeep(float pitch);
|
||||
@@ -23,6 +25,7 @@ private:
|
||||
Array array_;
|
||||
std::unique_ptr<Sorter> currentSorter_;
|
||||
UI ui_;
|
||||
OperationsHistory opsHistory_;
|
||||
bool isPlaying_;
|
||||
float timeSinceLastStep_;
|
||||
int stepsPerFrame_;
|
||||
@@ -37,4 +40,7 @@ private:
|
||||
|
||||
size_t lastComparisons_;
|
||||
size_t lastSwaps_;
|
||||
|
||||
sf::Font histogramFont_;
|
||||
bool histogramFontLoaded_;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <deque>
|
||||
#include <cstddef>
|
||||
|
||||
class OperationsHistory {
|
||||
public:
|
||||
OperationsHistory(size_t maxSamples = 300);
|
||||
|
||||
void record(size_t comparisons);
|
||||
void reset();
|
||||
const std::deque<size_t>& getHistory() const;
|
||||
size_t getMaxValue() const;
|
||||
|
||||
private:
|
||||
std::deque<size_t> compareHistory_;
|
||||
size_t maxSamples_;
|
||||
};
|
||||
Reference in New Issue
Block a user