seq-range-array.h revision e4cebacdec9c9e5b685dde5f7cbf7a5cf7e1d248
94ba4820927b906b333e39445c1508a29387c3aaTimo SirainenARRAY_DEFINE_TYPE(seq_range, struct seq_range);
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen/* Add sequrence to range. If the array isn't created yet, create it with
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen initial size of init_count. */
f330fcc3307d48954b6f8909349546773368a041Timo Sirainenvoid seq_range_array_add(ARRAY_TYPE(seq_range) *array, unsigned int init_count,
f24b245f49b030d7dba3bcb2463cbc05b98c9d1dTimo Sirainenvoid seq_range_array_add_range(ARRAY_TYPE(seq_range) *array,
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainenvoid seq_range_array_merge(ARRAY_TYPE(seq_range) *dest,
f23baa3b53b1dd4eb19729e99a43937fa3c7f309Timo Sirainen/* Remove given sequrence from range. Returns TRUE if it was found. */
8732bdd21579472feb40da8ffc99b8fd3b341417Timo Sirainenbool seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
7f098e28ddad259d9fbe76e18347c722bb005189Timo Sirainen/* Remove a sequence range. Returns number of sequences actually removed. */
7f098e28ddad259d9fbe76e18347c722bb005189Timo Sirainenunsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainenunsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen/* Remove sequences from dest that don't exist in src.
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen Returns the number of sequences actually removed. */
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainenseq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
8732bdd21579472feb40da8ffc99b8fd3b341417Timo Sirainen/* Returns TRUE if sequence exists in the range. */
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainenbool seq_range_exists(const ARRAY_TYPE(seq_range) *array, uint32_t seq);
2d7da70c0e6768afeb1200c95f3e1293f2e502c6Timo Sirainen/* Returns TRUE if arrays have common sequences. */
2d7da70c0e6768afeb1200c95f3e1293f2e502c6Timo Sirainenbool seq_range_array_have_common(const ARRAY_TYPE(seq_range) *array1,
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen/* Return number of sequences in the range. */
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainenunsigned int seq_range_count(const ARRAY_TYPE(seq_range) *array);
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen/* Invert the sequence range. For example 5:6 -> min_seq:4,7:max_seq. */
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainenvoid seq_range_array_invert(ARRAY_TYPE(seq_range) *array,
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainenvoid seq_range_array_iter_init(struct seq_range_iter *iter_r,
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen/* Get the nth sequence (0 = first). Returns FALSE if idx is too large. */
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainenbool seq_range_array_iter_nth(struct seq_range_iter *iter, unsigned int n,