本文整理汇总了C++中DynamicList::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicList::getLength方法的具体用法?C++ DynamicList::getLength怎么用?C++ DynamicList::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicList
的用法示例。
在下文中一共展示了DynamicList::getLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sortAmountController
void ControllerClass::sortAmountController(DynamicList & lista){
DomainClass aux,aux1;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for (int i = 0;i < lista.getLength()-1; ++i)
for(int j = i+1; j < lista.getLength(); ++j)
if (lista[i].getAmount() > lista[j].getAmount())
{
aux = lista[i];
aux1 = lista[j];
lista.updatePosition(i,aux1);
lista.updatePosition(j,aux);
}
}
示例2: sortTypeControllerDesc
void ControllerClass::sortTypeControllerDesc(DynamicList & lista){
DomainClass aux,aux1;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for (int i = 0;i <= lista.getLength()-1; ++i)
for(int j = i;j < lista.getLength(); ++j)
if (strcmp(lista[i].getType(),lista[j].getType()) < 0)
{
aux = lista[i];
aux1 = lista[j];
lista.updatePosition(i,aux1);
lista.updatePosition(j,aux);
}
}
示例3: findByType
int ControllerClass::findByType(char* tip) {
DynamicList lista;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for (int pozitia = 0;pozitia < lista.getLength() ;++pozitia)
if(strcmp(lista[pozitia].getType(),tip) == 0)
return pozitia;
return -1;
}
示例4: findById
/*
Functia cauta o cheltuiala dupa numar,daca ea apare ii va return pozitia
cheltielii in lista si in caz contrar va returna 0
*/
int ControllerClass::findById(int id) {
DynamicList lista;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for (int pozitia = 0;pozitia < lista.getLength(); ++pozitia)
if(lista[pozitia].getId() == id)
return pozitia;
return -1;
lista.~DynamicList();
}
示例5: filterTypeController
void ControllerClass::filterTypeController(char* tip) {
DomainClass* filtrate = new DomainClass[100];
int contor = 0;
DynamicList lista;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for( int i = 0; i < lista.getLength(); ++i)
if (strcmp(lista[i].getType(),tip) == 0) {
contor ++;
filtrate [contor] = lista[i];
}
for( int i = 1; i <= contor; ++i)
filtrate[i].print();
cout << endl;
delete[] filtrate;
}
示例6: loadFromFlie
/*
Iau elementele de tip cheltuiala din fisier si le pun in
lista
*/
void RepositoryClass::loadFromFlie(DynamicList & lista) {
int id;
int number;
float amount;
char type[10];
ifstream fin("expenses.txt");
char c2;
int i = 1;
do{
fin >> id >> number >> amount >> type;
c2 = fin.peek();
lista.append(DomainClass::DomainClass(id,number,amount,type));
}while(c2 == '\n');
//imi pune tot timpul un caracter in plus asa ca il fac gol si scad iter
lista.deletePosition(lista.getLength()-1);
fin.close();
}
示例7: filterAmountController
/*
Functie de tipul DomainClass care va returna o lista care contine cheltuielile cu suma mai mare de
cat suma primita ca parametru
*/
void ControllerClass::filterAmountController(float suma) {
DomainClass* filtrate = new DomainClass[100];
int contor = 0;
DynamicList lista;
RepositoryClass rep = RepositoryClass::RepositoryClass();
rep.loadFromFlie(lista);
for( int i = 0; i < lista.getLength(); ++i)
if (lista[i].getAmount() >= suma) {
contor ++;
filtrate [contor] = lista[i];
}
for( int i = 1; i <= contor; ++i)
filtrate[i].print();
delete[] filtrate;
//lista.~DynamicList();
cout << endl;
}
示例8: saveInFile
void RepositoryClass::saveInFile(DynamicList & lista) {
ofstream fout("expenses.txt");
for (int i = 0;i < lista.getLength() ;++i)
fout<<lista[i].getId()<<" "<<lista[i].getNumber()<<" "<<lista[i].getAmount()<<" "<< lista[i].getType()<<'\n';
fout.close();
}