annotate TaskManager/Test/test_render/spe/TileHash.cpp @ 266:5c9dbd54cd51

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:00:09 +0900
parents 56be4a6e5513
children 907bda4a1a14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
1 #include <string.h>
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
2 #include <stdlib.h>
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
3 #include "TileHash.h"
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
4
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
5 static unsigned short PRIME[8] = {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
6 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd,
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
7 };
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
8
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
9 int
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
10 TileHash::hash(uint32 data)
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
11 {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
12 int value = 0;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
13 int n = 0;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
14 int key;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
15
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
16 for (int i = 0; i < 8; i ++) {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
17 key = data & 0xf;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
18 value += key * PRIME[n++];
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
19 data >>= 4;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
20 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
21
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
22 return value % hashSize;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
23 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
24
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
25 TileHash::TileHash(void)
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
26 {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
27 hashSize = 263;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
28 tableSize = sizeof(TilePtr)*hashSize;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
29
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
30 table = (TilePtr*)malloc(tableSize);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
31 clear();
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
32 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
33
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
34 int
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
35 TileHash::put(uint32 *key, TilePtr data)
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
36 {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
37 int hashval = hash((uint32)key);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
38
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
39 for (int i = 0; i < hashSize/2; i++) {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
40 int index = (hashval + i*i)%hashSize;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
41
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
42 if (table[index] == 0) {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
43 table[index] = data;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
44 return index;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
45 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
46 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
47
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
48 return -1;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
49 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
50
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
51 TilePtr
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
52 TileHash::get(uint32 *key)
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
53 {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
54 int hashval = hash((uint32)key);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
55
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
56 for (int i = 0; i < hashSize/2; i++) {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
57 int index = (hashval + i*i)%hashSize;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
58
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
59 if (table[index] != NULL &&
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
60 table[index]->texture_addr == key) {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
61 return table[index];
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
62 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
63 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
64
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
65 return NULL;
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
66 }
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
67
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
68 void
173
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
69 TileHash::remove(uint32 *key)
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
70 {
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
71 int hashval = hash((uint32)key);
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
72
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
73 for (int i = 0; i < hashSize/2; i++) {
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
74 int index = (hashval + i*i)%hashSize;
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
75
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
76 if (table[index] != NULL &&
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
77 table[index]->texture_addr == key) {
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
78 table[index] = NULL;
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
79 }
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
80 }
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
81 }
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
82
56be4a6e5513 add scale
gongo@localhost.localdomain
parents: 167
diff changeset
83 void
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
84 TileHash::clear(void)
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
85 {
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
86 bzero(table, tableSize);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
diff changeset
87 }