38 #ifndef included_sparse_vec_h 39 #define included_sparse_vec_h 53 #define SPARSE_VEC_IS_RANGE (1 << 0) 54 #define SPARSE_VEC_IS_VALID_RANGE (1 << 1) 65 #define SPARSE_VEC_INVALID_INDEX (0) 74 ASSERT (sparse_index_bits <= 16);
117 is_member = (w & b) != 0;
121 u8 is_range, is_valid_range;
126 is_member = is_range ? is_valid_range : is_member;
131 *insert = ! is_member;
144 d = is_member ? d : 0;
146 return is_member + d;
160 u32 * i0_return,
u32 * i1_return)
163 uword b0, b1, w0, w1, v0, v1;
165 u8 is_member0, is_member1;
198 is_member0 = (w0 & b0) != 0;
199 is_member1 = (w1 & b1) != 0;
201 d0 = is_member0 ? d0 : 0;
202 d1 = is_member1 ? d1 : 0;
204 *i0_return = is_member0 + d0;
205 *i1_return = is_member1 + d1;
208 #define sparse_vec_free(v) vec_free(v) 210 #define sparse_vec_elt_at_index(v,i) \ 211 vec_elt_at_index ((v), sparse_vec_index ((v), (i))) 213 #define sparse_vec_validate(v,i) \ 219 (v) = sparse_vec_new (sizeof ((v)[0]), BITS (u16)); \ 221 _i = sparse_vec_index_internal ((v), (i), \ 225 vec_insert_ha ((v), 1, _i, \ 226 sizeof (sparse_vec_header_t), \ sll srl srl sll sra u16x4 i
#define SPARSE_VEC_IS_RANGE
always_inline uword sparse_vec_index_internal(void *v, uword sparse_index, uword maybe_range, u32 *insert)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
always_inline uword count_set_bits(uword x)
always_inline void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
always_inline sparse_vec_header_t * sparse_vec_header(void *v)
always_inline uword is_pow2(uword x)
always_inline void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define SPARSE_VEC_IS_VALID_RANGE
always_inline void * vec_header(void *v, uword header_bytes)
Find a user vector header.
always_inline uword min_log2(uword x)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
always_inline uword sparse_vec_index(void *v, uword sparse_index)