Esempio n. 1
0
size_t
array_delete(array_t *array, size_t at) {
    if (array_check_bounds(array, at, 0) == BOUNDS_OK) {
        if (at < --array->e_end) {
            void *ptr = array_get(array, at);
            size_t to_move = array->e_end - at;
            if (to_move > 0)
                memmove(ptr, ptr + array->e_size, to_move * array->e_size);
        }
        return array->e_end;
    }
    return (size_t)-1;
}
Esempio n. 2
0
void *
array_new_at(array_t *array, size_t index) {
    if (array_check_bounds(array, index, 1) == BOUNDS_FAIL)
        return NULL;
    // do this first, in case the array needs to move (via realloc)
    array_check_alloc(array, 1);
    void *ptr = array->data + index * array->e_size;
    if (ptr != NULL) {
        size_t to_move = array->e_end - index;
        if (to_move > 0)
            memmove(ptr + array->e_size, ptr, array->e_size * to_move);
        ++array->e_end;
        memset(ptr, '\0', array->e_size);
    }
    return ptr;
}
 KOKKOS_INLINE_FUNCTION
 T operator[]( const iType & i ) const
   { 
     array_check_bounds(i,lhs.size());
     return KOKKOS_CORE_UNARY_FUNCTION_MEMBER( lhs[i] );
   }
 KOKKOS_INLINE_FUNCTION
 TypeRHS operator[]( const iType & i ) const
   {
     array_check_bounds(i,rhs.size());
     return KOKKOS_CORE_UNARY_OPERATOR rhs[i] ;
   }
Esempio n. 5
0
 KOKKOSARRAY_INLINE_FUNCTION
 const volatile value_type & operator[]( const iType & i ) const
   { array_check_bounds(i,count.N); return elems[i*stride] ; }
Esempio n. 6
0
 KOKKOSARRAY_INLINE_FUNCTION
 value_type & operator[]( const iType & i )
   { array_check_bounds(i,count.N); return elems[i]; }
Esempio n. 7
0
void *
array_get(array_t *array, size_t index) {
    if (array_check_bounds(array, index, 0) == BOUNDS_FAIL)
        return NULL;
    return array->data + index * array->e_size;
}