Esempio n. 1
0
bool @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ min_value , @TYPE@ max_value , @TYPE@ delta) {
  if (max_value >= min_value) {
    @TYPE@ current_value = min_value;
    @TYPE@_vector_reset( vector );
    while (current_value < max_value) {
      @TYPE@_vector_append( vector , current_value );
      current_value += delta;
    }
    @TYPE@_vector_append( vector , max_value );
    return true;
  } else
    return false;
}
Esempio n. 2
0
void @TYPE@_vector_range_fill(@TYPE@_vector_type * vector , @TYPE@ limit1 , @TYPE@ delta , @TYPE@ limit2) {
  @TYPE@ current_value = limit1;

  if (delta == 0)
    util_abort("%s: sorry can not have delta == 0 \n",__func__);

  @TYPE@_vector_reset( vector );
  while (true) {
    @TYPE@_vector_append( vector , current_value );
    current_value += delta;
    if (delta > 0 && current_value > limit2)
      break;

    if (delta < 0 && current_value < limit2)
      break;
  }
}
Esempio n. 3
0
void @TYPE@_vector_select_unique(@TYPE@_vector_type * vector) {
  @TYPE@_vector_assert_writable( vector ); 
  {
    @TYPE@_vector_type * copy = @TYPE@_vector_alloc_copy( vector );
    @TYPE@_vector_sort( copy );
    @TYPE@_vector_reset( vector );
    {
      int i;
      @TYPE@ previous_value = @TYPE@_vector_iget( copy , 0);
      @TYPE@_vector_append( vector , previous_value);
      
      for (i=1; i <  copy->size; i++) {
        @TYPE@ value = @TYPE@_vector_iget( copy , i );
        if (value != previous_value)
          @TYPE@_vector_append( vector , value);
        previous_value = value;
      }
    }
    @TYPE@_vector_free( copy );
  }
}
Esempio n. 4
0
void @TYPE@_vector_reset__(void * __vector) {
  @TYPE@_vector_type * vector = @TYPE@_vector_safe_cast( __vector );
  @TYPE@_vector_reset( vector );
}
Esempio n. 5
0
void @TYPE@_vector_free_data(@TYPE@_vector_type * vector) {
  @TYPE@_vector_reset(vector);
  @TYPE@_vector_realloc_data__(vector , 0);
}
Esempio n. 6
0
void @TYPE@_vector_memcpy( @TYPE@_vector_type * target, const @TYPE@_vector_type * src ) {
  @TYPE@_vector_reset( target );
  target->default_value = src->default_value;

  @TYPE@_vector_memcpy_data_block( target  , src , 0 , 0 , src->size );
}
Esempio n. 7
0
void @TYPE@_vector_memcpy_from_data( @TYPE@_vector_type * target , const @TYPE@ * src , int src_size ) {
  @TYPE@_vector_reset( target );
  @TYPE@_vector_iset( target , src_size - 1 , 0 );
  memcpy( target->data , src , src_size * sizeof * target->data );
}