38 #ifndef included_sparse_vec_h 39 #define included_sparse_vec_h 54 #define SPARSE_VEC_IS_RANGE (1 << 0) 55 #define SPARSE_VEC_IS_VALID_RANGE (1 << 1) 68 #define SPARSE_VEC_INVALID_INDEX (0) 77 ASSERT (sparse_index_bits <= 16);
119 is_member = (w & b) != 0;
123 u8 is_range, is_valid_range;
128 is_member = is_range ? is_valid_range : is_member;
133 *insert = !is_member;
146 d = is_member ? d : 0;
148 return is_member + d;
164 uword b0, b1, w0, w1, v0, v1;
166 u8 is_member0, is_member1;
199 is_member0 = (w0 & b0) != 0;
200 is_member1 = (w1 & b1) != 0;
202 d0 = is_member0 ? d0 : 0;
203 d1 = is_member1 ? d1 : 0;
205 *i0_return = is_member0 + d0;
206 *i1_return = is_member1 + d1;
209 #define sparse_vec_free(v) vec_free(v) 211 #define sparse_vec_elt_at_index(v,i) \ 212 vec_elt_at_index ((v), sparse_vec_index ((v), (i))) 214 #define sparse_vec_validate(v,i) \ 220 (v) = sparse_vec_new (sizeof ((v)[0]), BITS (u16)); \ 222 _i = sparse_vec_index_internal ((v), (i), \ 226 vec_insert_ha ((v), 1, _i, \ 227 sizeof (sparse_vec_header_t), \ sll srl srl sll sra u16x4 i
#define SPARSE_VEC_IS_RANGE
static uword min_log2(uword x)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
static void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
static sparse_vec_header_t * sparse_vec_header(void *v)
static uword sparse_vec_index(void *v, uword sparse_index)
static uword is_pow2(uword x)
static uword sparse_vec_index_internal(void *v, uword sparse_index, uword maybe_range, u32 *insert)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define SPARSE_VEC_IS_VALID_RANGE
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
static uword count_set_bits(uword x)
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".