improved Array: use std::vector
This commit is contained in:
@@ -38,18 +38,19 @@ public:
|
||||
}
|
||||
//-
|
||||
void print() {
|
||||
for (long i = 0; i < this->length; ++i)
|
||||
this->elements[i]->print();
|
||||
for (auto& elem : this->getElements())
|
||||
elem->print();
|
||||
}
|
||||
|
||||
void init(const char* fileName, int recordSize) {
|
||||
state = WorkspacesCreation;
|
||||
File* packedTasks = new File(fileName);
|
||||
Text* lines = packedTasks->readLines();
|
||||
this->length = lines->getLength() / recordSize;
|
||||
this->elements = new T * [this->length];
|
||||
|
||||
const long length = lines->getLength() / recordSize;
|
||||
int offset = 0;
|
||||
for (int i = 0; i < this->length; ++i) {
|
||||
this->elements[i] = new T(lines, offset);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
this->add(new T(lines, offset));
|
||||
offset += recordSize;
|
||||
}
|
||||
delete packedTasks;
|
||||
@@ -59,13 +60,13 @@ public:
|
||||
saveState();
|
||||
long activeCount = 0;
|
||||
//todo обязательно убрать отладочную печать.
|
||||
printf("tasks count = %ld\n", this->length);
|
||||
printf("tasks count = %ld\n", this->getLength());
|
||||
while (this->state != End) {
|
||||
// printf("state=%d\n", this->state);
|
||||
// printf("max=%d; busy=%d; free=%d\n", maxKernels, busyKernels, freeKernels);
|
||||
activeCount = 0;
|
||||
for (long i = 0; i < this->length; ++i) {
|
||||
T* task = this->elements[i];
|
||||
for (long i = 0; i < this->getLength(); ++i) {
|
||||
T* task = this->get(i);
|
||||
switch (this->state) {
|
||||
case WorkspacesCreation:
|
||||
if (task->getState() == Waiting) {
|
||||
|
||||
Reference in New Issue
Block a user