コード例 #1
0
ファイル: lookuptable.cpp プロジェクト: marnen/rubinius
  void LookupTable::redistribute(STATE, size_t size) {
    size_t num = bins_->to_native();
    Tuple* new_values = Tuple::create(state, size);

    for(size_t i = 0; i < num; i++) {
      Tuple* entry = try_as<Tuple>(values_->at(state, i));

      while(entry) {
        Tuple* link = try_as<Tuple>(entry->at(state, 2));
        entry->put(state, 2, Qnil);

        size_t bin = find_bin(key_hash(entry->at(state, 0)), size);
        Tuple* slot = try_as<Tuple>(new_values->at(state, bin));

        if(!slot) {
          new_values->put(state, bin, entry);
        } else {
          entry_append(state, slot, entry);
        }

        entry = link;
      }
    }

    values(state, new_values);
    bins(state, Fixnum::from(size));
  }
コード例 #2
0
ファイル: array.c プロジェクト: project8/adiP8
void array_append(Array* array, double x)
{
  if(!array->last) {
    Entry *entry = entry_new();
    array->start = entry;
    array->last = entry;
  }

  Entry *old = array->last;
  array->last = entry_append(array->last, x);
  if(old != array->last)
    array->size++;
}
コード例 #3
0
ファイル: array.c プロジェクト: project8/adiP8
Entry* entry_append(Entry* entry, double x)
{
  if(entry->size < BLOCKSIZE) {
    entry->data[entry->size] = x;
    entry->size++;
    return entry;
  }
  else {
    Entry *newentry = entry_new();
    entry->next = newentry;
    entry_append(newentry, x);
    return newentry;
  }
}