warning fixes

This commit is contained in:
Hisham Muhammad
2010-02-25 01:43:18 +00:00
parent 5cc8998688
commit 02a30bfecd
35 changed files with 179 additions and 171 deletions

View File

@ -127,37 +127,37 @@ static void Vector_checkArraySize(Vector* this) {
assert(Vector_isConsistent(this));
}
void Vector_insert(Vector* this, int index, void* data_) {
assert(index >= 0);
void Vector_insert(Vector* this, int idx, void* data_) {
assert(idx >= 0);
assert(((Object*)data_)->class == this->vectorType);
Object* data = data_;
assert(Vector_isConsistent(this));
Vector_checkArraySize(this);
assert(this->array[this->items] == NULL);
for (int i = this->items; i >= index; i--) {
for (int i = this->items; i >= idx; i--) {
this->array[i+1] = this->array[i];
}
this->array[index] = data;
this->array[idx] = data;
this->items++;
assert(Vector_isConsistent(this));
}
Object* Vector_take(Vector* this, int index) {
assert(index >= 0 && index < this->items);
Object* Vector_take(Vector* this, int idx) {
assert(idx >= 0 && idx < this->items);
assert(Vector_isConsistent(this));
Object* removed = this->array[index];
Object* removed = this->array[idx];
assert (removed != NULL);
this->items--;
for (int i = index; i < this->items; i++)
for (int i = idx; i < this->items; i++)
this->array[i] = this->array[i+1];
this->array[this->items] = NULL;
assert(Vector_isConsistent(this));
return removed;
}
Object* Vector_remove(Vector* this, int index) {
Object* removed = Vector_take(this, index);
Object* Vector_remove(Vector* this, int idx) {
Object* removed = Vector_take(this, idx);
if (this->owner) {
removed->delete(removed);
return NULL;
@ -165,52 +165,52 @@ Object* Vector_remove(Vector* this, int index) {
return removed;
}
void Vector_moveUp(Vector* this, int index) {
assert(index >= 0 && index < this->items);
void Vector_moveUp(Vector* this, int idx) {
assert(idx >= 0 && idx < this->items);
assert(Vector_isConsistent(this));
if (index == 0)
if (idx == 0)
return;
Object* temp = this->array[index];
this->array[index] = this->array[index - 1];
this->array[index - 1] = temp;
Object* temp = this->array[idx];
this->array[idx] = this->array[idx - 1];
this->array[idx - 1] = temp;
}
void Vector_moveDown(Vector* this, int index) {
assert(index >= 0 && index < this->items);
void Vector_moveDown(Vector* this, int idx) {
assert(idx >= 0 && idx < this->items);
assert(Vector_isConsistent(this));
if (index == this->items - 1)
if (idx == this->items - 1)
return;
Object* temp = this->array[index];
this->array[index] = this->array[index + 1];
this->array[index + 1] = temp;
Object* temp = this->array[idx];
this->array[idx] = this->array[idx + 1];
this->array[idx + 1] = temp;
}
void Vector_set(Vector* this, int index, void* data_) {
assert(index >= 0);
void Vector_set(Vector* this, int idx, void* data_) {
assert(idx >= 0);
assert(((Object*)data_)->class == this->vectorType);
Object* data = data_;
assert(Vector_isConsistent(this));
Vector_checkArraySize(this);
if (index >= this->items) {
this->items = index+1;
if (idx >= this->items) {
this->items = idx+1;
} else {
if (this->owner) {
Object* removed = this->array[index];
Object* removed = this->array[idx];
assert (removed != NULL);
if (this->owner) {
removed->delete(removed);
}
}
}
this->array[index] = data;
this->array[idx] = data;
assert(Vector_isConsistent(this));
}
inline Object* Vector_get(Vector* this, int index) {
assert(index < this->items);
inline Object* Vector_get(Vector* this, int idx) {
assert(idx < this->items);
assert(Vector_isConsistent(this));
return this->array[index];
return this->array[idx];
}
inline int Vector_size(Vector* this) {