14 class binmap_t : Serializable {
17 typedef int32_t bitmap_t;
18 /** Type of reference */
19 typedef uint32_t ref_t;
37 void set(const bin_t& bin);
43 void reset(const bin_t& bin);
53 * Ric: Fill all bins, size is given by the source's root
55 void fill(const binmap_t& source);
59 * Whether binmap is empty
61 bool is_empty() const;
65 * Whether binmap is filled
67 bool is_filled() const;
71 * Whether range/bin is empty
73 bool is_empty(const bin_t& bin) const;
77 * Whether range/bin is filled
79 bool is_filled(const bin_t& bin) const;
83 * Return the topmost solid bin which covers the specified bin
85 bin_t cover(const bin_t& bin) const;
89 * Find first empty bin
91 bin_t find_empty() const;
95 * Find first filled bin
97 bin_t find_filled() const;
101 * Get number of allocated cells
103 size_t cells_number() const;
107 * Get total size of the binmap (Arno: =number of bytes it occupies in memory)
109 size_t total_size() const;
113 * Echo the binmap status to stdout
119 * Find first additional bin in source
121 static bin_t find_complement(const binmap_t& destination, const binmap_t& source, const bin_t::uint_t twist);
125 * Find first additional bin of the source inside specified range
127 static bin_t find_complement(const binmap_t& destination, const binmap_t& source, bin_t range, const bin_t::uint_t twist);
131 * Copy one binmap to another
133 static void copy(binmap_t& destination, const binmap_t& source);
137 * Copy a range from one binmap to another binmap
139 static void copy(binmap_t& destination, const binmap_t& source, const bin_t& range);
142 // Arno, 2011-10-20: Persistent storage
143 int serialize(FILE *fp);
144 int deserialize(FILE *fp);
146 #pragma pack(push, 1)
149 * Structure of cell halves
165 bool is_left_ref_ : 1;
166 bool is_right_ref_ : 1;
176 /** Allocates one cell (dirty allocation) */
179 /** Allocates one cell */
182 /** Reserve cells allocation capacity */
183 bool reserve_cells(size_t count);
185 /** Releases the cell */
186 void free_cell(ref_t cell);
191 /** Pack a trace of cells */
192 void pack_cells(ref_t* cells);
195 /** Pointer to the list of blocks */
198 /** Number of available cells */
199 size_t cells_number_;
201 /** Number of allocated cells */
202 size_t allocated_cells_number_;
204 /** Front of the free cell list */
212 void trace(ref_t* ref, bin_t* bin, const bin_t& target) const;
215 void trace(ref_t* ref, bin_t* bin, ref_t** history, const bin_t& target) const;
218 /** Sets low layer bitmap */
219 void _set__low_layer_bitmap(const bin_t& bin, const bitmap_t bitmap);
221 /** Sets high layer bitmap */
222 void _set__high_layer_bitmap(const bin_t& bin, const bitmap_t bitmap);
225 /** Clone binmap cells to another binmap */
226 static void copy(binmap_t& destination, const ref_t dref, const binmap_t& source, const ref_t sref);
228 static void _copy__range(binmap_t& destination, const binmap_t& source, const ref_t sref, const bin_t sbin);
231 /** Find first additional bin in source */
232 static bin_t _find_complement(const bin_t& bin, const ref_t dref, const binmap_t& destination, const ref_t sref, const binmap_t& source, const bin_t::uint_t twist);
233 static bin_t _find_complement(const bin_t& bin, const bitmap_t dbitmap, const ref_t sref, const binmap_t& source, const bin_t::uint_t twist);
234 static bin_t _find_complement(const bin_t& bin, const ref_t dref, const binmap_t& destination, const bitmap_t sbitmap, const bin_t::uint_t twist);
235 static bin_t _find_complement(const bin_t& bin, const bitmap_t dbitmap, const bitmap_t sbitmap, const bin_t::uint_t twist);
239 binmap_t& operator = (const binmap_t&);
242 binmap_t(const binmap_t&);
244 // Arno, 2011-10-20: Persistent storage
245 int write_cell(FILE *fp,cell_t c);
246 int read_cell(FILE *fp,cell_t *c);
251 #endif /*_binmap_h__*/