Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
bin.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19//
20// Bin.h
21//
22
23
24#ifndef __BIN_H
25#define __BIN_H
26
27#include "list.h"
28#include "OLEString.h"
29
30class BinItem: public ListNode
31{
32 int hash;
33 OLECHAR *text1;
34 int text1size;
35 OLECHAR *text2;
36 int text2size;
37
38 public:
39 BinItem ( void *data, int hash, OLECHAR *text1, OLECHAR *text2 );
40 int Same ( int chash, OLECHAR *ctext1, int size1, OLECHAR *ctext2, int size2 );
41
42};
43
44class Bin
45{
46 List *bucket;
47 int num_buckets;
48 BinItem *sh_item;
49 int sh_size1,sh_size2;
50 int sh_hash;
51 OLECHAR *sh_text1, *sh_text2;
52
53 int calc_hash ( OLECHAR *text );
54
55 public:
56
57 Bin ( int size = 256 );
58 ~Bin ();
59
60 void Clear ( void );
61 void* Get ( OLECHAR *text1, OLECHAR *text2 = NULL );
62 void* GetNext ( void );
63 void Add ( void *item, OLECHAR *text1, OLECHAR *text2 = NULL );
64 BinItem* GetBinItem ( OLECHAR *text1, OLECHAR *text2 = NULL );
65 BinItem* GetBinItem ( void *item );
66 BinItem* GetNextBinItem ( void );
67 void Remove ( void *item );
68 void Remove ( OLECHAR *text1, OLECHAR *text2 = NULL );
69 void Remove ( BinItem *item );
70
71
72};
73
74
75class BinIDItem: public ListNode
76{
77 int id;
78
79 public:
80 BinIDItem ( void *data, int id );
81 int Same ( int id );
82
83};
84
85class BinID
86{
87 List *bucket;
88 int num_buckets;
89
90 public:
91
92 BinID ( int size = 256 );
93 ~BinID ();
94
95 void Clear ( void );
96 void* Get ( int id );
97 void Add ( void *item, int id );
98 BinIDItem* GetBinIDItem ( int id );
99 BinIDItem* GetBinIDItem ( void *item );
100 void Remove ( void *item );
101 void Remove ( int id );
102 void Remove ( BinIDItem *item );
103
104
105};
106
107
108#endif // __BIN_H
#define NULL
Definition BaseType.h:92
void Add(void *item, OLECHAR *text1, OLECHAR *text2=NULL)
Definition bin.cpp:89
void Clear(void)
Definition bin.cpp:48
Bin(int size=256)
Definition bin.cpp:28
void * Get(OLECHAR *text1, OLECHAR *text2=NULL)
Definition bin.cpp:65
~Bin()
Definition bin.cpp:38
void * GetNext(void)
Definition bin.cpp:77
BinItem * GetNextBinItem(void)
Definition bin.cpp:131
void Remove(void *item)
Definition bin.cpp:170
BinItem * GetBinItem(OLECHAR *text1, OLECHAR *text2=NULL)
Definition bin.cpp:106
BinIDItem * GetBinIDItem(int id)
Definition bin.cpp:323
void * Get(int id)
Definition bin.cpp:297
void Add(void *item, int id)
Definition bin.cpp:309
~BinID()
Definition bin.cpp:270
BinID(int size=256)
Definition bin.cpp:261
void Remove(void *item)
Definition bin.cpp:363
void Clear(void)
Definition bin.cpp:280
int Same(int id)
Definition bin.cpp:400
BinIDItem(void *data, int id)
Definition bin.cpp:393
Definition bin.h:31
int Same(int chash, OLECHAR *ctext1, int size1, OLECHAR *ctext2, int size2)
Definition bin.cpp:225
BinItem(void *data, int hash, OLECHAR *text1, OLECHAR *text2)
Definition bin.cpp:201
Definition list.h:60
ListNode(void)
Definition list.cpp:28