-
Notifications
You must be signed in to change notification settings - Fork 7
/
Holding.h
41 lines (36 loc) · 817 Bytes
/
Holding.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
#ifndef __DDS_HOLDING_H__
#define __DDS_HOLDING_H__
#include "ddsInterface.h"
/*
* This is just a utility class so you can say:
* cout << Holding(h) << endl;
* when h is of type holding_t.
*/
struct Holding {
holding_t _h;
inline Holding(holding_t h) : _h(h) { }
inline operator holding_t() const {
return _h;
}
inline const Holding &operator=(holding_t h) {
_h = h;
return *this;
}
};
inline ostream& operator <<(ostream &out,const Holding &holding) {
static const char *cards="AKQJT98765432";
int index=0;
holding_t h = holding._h;
if (h&8191) {
for (holding_t card=1<<12; card; card >>= 1, index++) {
if (h & card) {
out << cards[index];
}
}
} else {
out << "void";
}
out << " (" << holding._h << ")";
return out;
}
#endif