-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPuzzlePiecesMap.h
More file actions
47 lines (36 loc) · 1.48 KB
/
Copy pathPuzzlePiecesMap.h
File metadata and controls
47 lines (36 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// PuzzlePieces.h
// AdvProgEX1
//
// Created by Alexander Shugaley on 09/12/2017.
// Copyright © 2017 Alexander Shugaley. All rights reserved.
//
#ifndef PuzzlePieces_h
#define PuzzlePieces_h
#include "PuzzleRequirement.h"
#include "PuzzlePiece.h"
#include <map>
/**
* Class for representing a puzzle pieces map - the 'tree' that holds the different pieces types. Will first sort the types to the different buckets (implemented as a map), and then provide search in 0(1).
*/
using namespace std;
class PuzzlePiecesMap{
protected:
map<PuzzleType,vector<PuzzlePiece>> typesMap;
public:
// Empty c'tor - used to initialize empty map that doesn't contain any values yet
explicit PuzzlePiecesMap();
//Vector of Puzzle pieces c'tor - also insert the vector's content into the map
//Uses the helper function toBuckets
explicit PuzzlePiecesMap(vector<PuzzlePiece>& pieces);
// Virtual destructor
virtual ~PuzzlePiecesMap() = default;
// Helper function to insert vector's content into the map (mapping using each piece's type)
virtual void toBuckets(vector<PuzzlePiece>& pieces);
// Getter function for the types map
virtual map<PuzzleType, vector<PuzzlePiece>>& getTypesMap();
// helper function for the solving algorithm - given a requirement returns a pointer
// to a puzzle piece that satisfies the requirement. if there isn't any - return nullptr
virtual PuzzlePiece* nextPiece(PuzzleRequirement& req);
};
#endif /* PuzzlePieces_h */