Rev 7771 | Rev 7885 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7771 | Rev 7878 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | int addn(); |
18 | int addn(); |
19 | dword get(); //get_name_by_pos |
19 | dword get(); //get_name_by_pos |
20 | dword get_pos_by_name(); |
20 | dword get_pos_by_name(); |
21 | void drop(); |
21 | void drop(); |
22 | void increase_data_size(); |
22 | void increase_data_size(); |
- | 23 | dword get_last(); |
|
- | 24 | bool delete_last(); |
|
23 | }; |
25 | }; |
Line 24... | Line 26... | ||
24 | 26 | ||
25 | :void collection::increase_data_size() { |
27 | :void collection::increase_data_size() { |
26 | int filled_size; |
28 | int filled_size; |
Line 38... | Line 40... | ||
38 | :int collection::add(dword in) { |
40 | :int collection::add(dword in) { |
39 | return addn(in, strlen(in)); |
41 | return addn(in, strlen(in)); |
40 | } |
42 | } |
Line 41... | Line 43... | ||
41 | 43 | ||
42 | :int collection::addn(dword in, len) { |
44 | :int collection::addn(dword in, len) { |
- | 45 | if (count >= 4000) { |
|
- | 46 | debugln("collection: more than 4000 elements!"); |
|
- | 47 | return 0; |
|
43 | if (count >= 4000) return 0; |
48 | } |
44 | if (element_offset[count]+len+2 > data_size) { |
49 | if (element_offset[count]+len+2 > data_size) { |
45 | increase_data_size(); |
50 | increase_data_size(); |
46 | addn(in, len); |
51 | addn(in, len); |
47 | return 1; |
52 | return 1; |
Line 55... | Line 60... | ||
55 | :dword collection::get(dword pos) { |
60 | :dword collection::get(dword pos) { |
56 | if (pos<0) || (pos>=count) return 0; |
61 | if (pos<0) || (pos>=count) return 0; |
57 | return data_start + element_offset[pos]; |
62 | return data_start + element_offset[pos]; |
58 | } |
63 | } |
Line -... | Line 64... | ||
- | 64 | ||
- | 65 | :dword collection::get_last() { |
|
- | 66 | return get(count-1); |
|
- | 67 | } |
|
59 | 68 | ||
60 | :dword collection::get_pos_by_name(dword name) { |
69 | :dword collection::get_pos_by_name(dword name) { |
61 | dword i; |
70 | dword i; |
62 | for (i=0; i |
71 | for (i=0; i |
63 | if (strcmp(data_start + element_offset[i], name)==0) return i; |
72 | if (strcmp(data_start + element_offset[i], name)==0) return i; |
Line 71... | Line 80... | ||
71 | data_start = 0; |
80 | data_start = 0; |
72 | element_offset[count] = 0; |
81 | element_offset[count] = 0; |
73 | count = 0; |
82 | count = 0; |
74 | } |
83 | } |
Line -... | Line 84... | ||
- | 84 | ||
- | 85 | :bool collection::delete_last() { |
|
- | 86 | count--; |
|
Line 75... | Line 87... | ||
75 | 87 | } |
|
76 | 88 | ||
77 | /*======================================================== |
89 | /*======================================================== |
78 | = = |
90 | = = |