wavelength 1.0.0
Loading...
Searching...
No Matches
trackselector.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
12public:
19 class TrackInfo {
20 public:
22 static constexpr int kNumSlots = 4;
23
31
40 int Find(int nPlayer) const;
41
49 int Count() const;
50
58 void Add(int nPlayer);
59
66 void Compact();
67
75 void Remove(int nPlayer);
76
78 const std::vector<int> &GetPlayers() const {
79 return mPlayers;
80 }
81
83 std::vector<int> &GetPlayers() {
84 return mPlayers;
85 }
86
93 void SetPlayer(int nSlot, int nPlayer) {
94 mPlayers[nSlot] = nPlayer;
95 }
96
97 private:
98 std::vector<int> mPlayers;
99 };
100
108 explicit TrackSelector(int nTracks);
109
117 void AddPlayer(int nTrack);
118
127 void AddPlayer(int nTrack, int nSlot);
128
136 int GetNumPlayers() const;
137
145 int GetNumTracks() const;
146
155 void SetPlayerTrack(int nPlayer, int nTrack);
156
169 void SwapPlayer(int nPlayer, int nTrack, int nSlot);
170
177 void Compact();
178
187 int GetPlayerTrack(int nPlayer) const;
188
197 int GetPlayerSlot(int nPlayer) const;
198
207 int GetFirstPlayer(int nTrack) const;
208
217 int GetNumPlayersOnTrack(int nTrack) const;
218
227 const int *GetPlayersOnTrack(int nTrack) const;
228
229private:
230 std::vector<int> mPlayerTracks;
231 std::vector<TrackInfo> mTrackInfos;
232 int mNeedsCompact;
233};
const std::vector< int > & GetPlayers() const
Definition trackselector.h:78
TrackInfo()
Construct a track with every slot empty.
void Remove(int nPlayer)
Take a player out of its slot and move the later players one slot down.
std::vector< int > & GetPlayers()
Definition trackselector.h:83
static constexpr int kNumSlots
The number of slots of a track.
Definition trackselector.h:22
void Add(int nPlayer)
Put a player in the slot after the occupied ones.
void Compact()
Move each player into the first slot of the run of empty slots before it.
int Find(int nPlayer) const
Report the slot of a player.
void SetPlayer(int nSlot, int nPlayer)
Put a player in a slot.
Definition trackselector.h:93
int Count() const
Report the number of occupied slots.
const int * GetPlayersOnTrack(int nTrack) const
Report the players on a track.
int GetNumPlayers() const
Report the number of players.
void SetPlayerTrack(int nPlayer, int nTrack)
Move a player to the first empty slot of a track, or off every track.
int GetNumPlayersOnTrack(int nTrack) const
Report the number of players on a track.
void AddPlayer(int nTrack, int nSlot)
Add the next player to a slot of a track.
int GetFirstPlayer(int nTrack) const
Report the player in the first slot of a track.
int GetPlayerTrack(int nPlayer) const
Report the track of a player.
void SwapPlayer(int nPlayer, int nTrack, int nSlot)
Swap a player with the player in a slot of a track.
int GetPlayerSlot(int nPlayer) const
Report the slot of a player on its track.
void AddPlayer(int nTrack)
Add the next player to the first empty slot of a track.
void Compact()
Compact every track after a swap.
TrackSelector(int nTracks)
Construct an assignment of no players to a number of tracks.
int GetNumTracks() const
Report the number of tracks.