1 ////////////////////////////////////////////////////////////////////////////////
7 // Author: Daniel Switkin
9 // Copyright 2003 (c) by Daniel Switkin. This file is made publically available
10 // under the BSD license, with the stipulations that this complete header must
11 // remain at the top of the file indefinitely, and credit must be given to the
12 // original author in any about box using this software.
14 ////////////////////////////////////////////////////////////////////////////////
16 // Additional authors: Stephan Aßmus, <superstippi@gmx.de>
17 // John Scipione, <jscipione@gmail.com>
26 SFHash::SFHash(int size
) {
29 iterate_pos
= iterate_depth
= 0;
30 main_array
= (HashItem
**)malloc(this->size
* sizeof(HashItem
*));
32 if (main_array
== NULL
) {
37 for (int x
= 0; x
< this->size
; x
++)
43 for (int x
= 0; x
< size
; x
++) {
44 HashItem
* item
= main_array
[x
];
45 while (item
!= NULL
) {
46 HashItem
* t
= item
->next
;
56 SFHash::AddItem(HashItem
* item
) {
58 int pos
= item
->key
% size
;
60 if (main_array
[pos
] == NULL
)
61 main_array
[pos
] = item
;
63 HashItem
* temp
= main_array
[pos
];
64 while (temp
->next
!= NULL
) temp
= temp
->next
;
71 SFHash::GetItem(unsigned int key
)
74 HashItem
* item
= main_array
[pos
];
76 while (item
!= NULL
) {
77 if (item
->key
== key
) return item
;
88 unsigned int count
= 0;
89 for (int x
= 0; x
< this->size
; x
++) {
90 HashItem
* item
= main_array
[x
];
91 while (item
!= NULL
) {
104 if (iterate_pos
>= size
) {
109 while ((item
= main_array
[iterate_pos
]) == NULL
)
112 for (int d
= 0; d
< iterate_depth
; d
++)
115 if (item
->next
!= NULL
)