-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemvector.h
53 lines (42 loc) · 1002 Bytes
/
itemvector.h
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
48
49
50
51
52
53
#ifndef ITEMVECTOR_H
#define ITEMVECTOR_H
#include "item.h"
#include <vector>
using namespace std;
class ItemVector {
private:
vector<Item*> items;
public:
ItemVector(){}
ItemVector(ItemVector* v){
items = v->items;
}
int getSize() const {
return items.size();
}
void removeItem(Item* item){
vector<Item*>::iterator it = find(items.begin(), items.end(), item);
if(it != items.end()){
items.erase(it);
}
}
// need this?
virtual bool smaller(int i, int j) const {
if(getItem(i) < getItem(j))
return true;
else
return false;
}
virtual void swap(int i, int j){
Item *temp = items[i];
items[i]=items[j];
items[j]=temp;
}
Item* getItem(int i) const{
return items[i];
}
void insertItem(Item* i) {
items.push_back(i);
}
};
#endif // ITEMVECTOR_H