/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Map.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-12 19:04:18 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150712190418-yi9rfito5ovnf6dy
* Made the code more easy to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "baseobject.h"
25
25
#include <stdlib.h>
26
26
 
27
 
struct SMapPrivate {
 
27
struct
 
28
SMapPrivate {
28
29
  size_t len; // Length
29
30
  SDynamicArray * array; /* This is what holds the buckets. These buckets are
30
31
                          * in turn also SDynamicArrays; or in template speak:
32
33
                          */
33
34
};
34
35
 
35
 
SMapItem * s_map_item_new (void * key, void * value) {
 
36
SMapItem *
 
37
s_map_item_new (void * key, void * value) {
36
38
  SMapItem * self = malloc (sizeof (SMapItem));
37
39
  self->key = key;
38
40
  self->value = value;
40
42
  return self;
41
43
}
42
44
 
43
 
void s_map_item_free (SMapItem * self, FuncPointer free_key,
 
45
void
 
46
s_map_item_free (SMapItem * self, FuncPointer free_key,
44
47
                                       FuncPointer free_value) {
45
48
  FREEFUNC(free_key) (self->key);
46
49
  FREEFUNC(free_value) (self->value);
49
52
 
50
53
 
51
54
 
52
 
SMap * s_map_new (CompFunc comp_func,
 
55
SMap *
 
56
s_map_new (CompFunc comp_func,
53
57
                  HashFunc key_hash_func,
54
58
                  FuncPointer free_key,
55
59
                  FuncPointer free_value) {
82
86
  return self;
83
87
}
84
88
 
85
 
void s_map_free (SMap * self) {
 
89
void
 
90
s_map_free (SMap * self) {
86
91
  
87
92
  
88
93
  free (self->priv);
91
96
}
92
97
 
93
98
 
94
 
void s_map_add (SMap * self, spointer key, spointer value) {
 
99
void
 
100
s_map_add (SMap * self, spointer key, spointer value) {
95
101
  SDynamicArray * array = self->priv->array;
96
102
  SMapItem * item = s_map_item_new (key, value);
97
103
  
123
129
  }
124
130
}
125
131
 
126
 
spointer s_map_get (SMap * self, spointer key) {
 
132
spointer
 
133
s_map_get (SMap * self, spointer key) {
127
134
  return NULL;
128
135
}
129
136
 
130
 
void s_map_remove (SMap * self, spointer key) {
 
137
void
 
138
s_map_remove (SMap * self, spointer key) {
131
139
  
132
140
}