seq-range-array.h revision c991d8c2c0d5d6c025e24fc00cb06dd61c42456d
bb10ebcf076c959c752f583746d83805d7686df8Timo SirainenARRAY_DEFINE_TYPE(seq_range, struct seq_range);
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainen/* Add sequrence to range. If the array isn't created yet, create it with
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainen initial size of init_count. Returns TRUE if seq was already in the array. */
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenbool seq_range_array_add(ARRAY_TYPE(seq_range) *array, unsigned int init_count,
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenvoid seq_range_array_add_range(ARRAY_TYPE(seq_range) *array,
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainenvoid seq_range_array_merge(ARRAY_TYPE(seq_range) *dest,
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen/* Remove given sequrence from range. Returns TRUE if it was found. */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainenbool seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen/* Remove a sequence range. Returns number of sequences actually removed. */
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainenunsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainenunsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Remove sequences from dest that don't exist in src.
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen Returns the number of sequences actually removed. */
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainenseq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen/* Returns TRUE if sequence exists in the range. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenbool seq_range_exists(const ARRAY_TYPE(seq_range) *array,
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen/* Returns TRUE if arrays have common sequences. */
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainenbool seq_range_array_have_common(const ARRAY_TYPE(seq_range) *array1,
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen const ARRAY_TYPE(seq_range) *array2) ATTR_PURE;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Return number of sequences in the range. */
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainenunsigned int seq_range_count(const ARRAY_TYPE(seq_range) *array) ATTR_PURE;
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainen/* Invert the sequence range. For example 5:6 -> min_seq:4,7:max_seq. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid seq_range_array_invert(ARRAY_TYPE(seq_range) *array,
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainenvoid seq_range_array_iter_init(struct seq_range_iter *iter_r,
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen/* Get the nth sequence (0 = first). Returns FALSE if idx is too large. */
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenbool seq_range_array_iter_nth(struct seq_range_iter *iter, unsigned int n,