Qt Creatorバージョン5.0.0ベータ版を使用してコードを記述し、MSVC2010とSP1を使用して、すべての更新をコンパイルに適用しています。
測量会社の仕事に関するメタ情報を格納するために定義したオブジェクトのベクトルを作成しています。
この構造体には、変数タイプ、変数名の順に次の情報を格納しています。
#pragma once
#ifndef JOB_H
#define JOB_H
#include "surveyman.h"
#include "client.h"
#include "contact.h"
#include "job.h"
#include "legallocation.h"
#include "location.h"
#include <string>
#include <time.h>
#include <QDate>
using namespace std;
class job
{
public:
job();
job(int newUI, int newJobNumber, string newAddendum, string newJobType,
string newDevelopmentName, QDate newDateReceived, string newNotes,
legalLocation newJobLocation, client newCustomer, int newTotalMoneyPaid)
;
static int uniqueIdentifier;
int jobNumber;
private:
int UI;
string addendum;
string jobType;
string developmentName;
QDate dateReceived;
string notes;
legalLocation jobLocation;
client customer;
int totalMoneyPaid;
};
#endif // JOB_H
#pragma once
#ifndef LOCATION_H
#define LOCATION_H
#include <string>
using namespace std;
class location
{
public:
location();
location(string, string, string, string, string, int, string, string, string);
string getAddressLine1();
void setAddressLine1(string);
string getAddressLine2();
void setAddressLine2(string);
string getAddressLine3();
void setAddressLine3(string);
string getAddressLine4();
void setAddressLine4(string);
string getLocality();
void setLocality(string);
string getStreet2();
void setStreet2(string);
string getAdditionalStreets();
void setAdditionalStreets(string);
string getAdditionalLocalities();
void setAdditionalLocalities(string);
int getUI();
int getPostCode();
void setPostCode(int);
string toString();
string getProvince(int);
static int uniqueIdentifier;
private:
int UI;
string addressLine1;
string addressLine2;
string addressLine3;
string addressLine4;
string locality;
int postCode;
string street2;
string additionalStreets;
string additionalLocalities;
};
#endif // LOCATION_H
#pragma once
#ifndef LEGALLOCATION_H
#define LEGALLOCATION_H
#include "location.h"
#include <string>
#include <vector>
using namespace std;
class legalLocation : public location
{
public:
legalLocation();
legalLocation(location basicLocoation, vector<vector<int> > folios);
legalLocation(string, string, string, string, string, int, string,
string, string, vector<vector<string> >);
vector<vector<string> > getFolios();
private:
vector<vector<string> > folios;
};
#endif // LEGALLOCATION_H
#pragma once
#ifndef CLIENT_H
#define CLIENT_H
#include "location.h"
#include "legallocation.h"
#include <string>
#include "contact.h"
using namespace std;
class client
{
public:
client();
client(string, string, string, string, string, location, vector<contact>);
client(int, string, string, string, string, string, location, vector<contact>);
static int uniqueIdentifier;
private:
int UI;
string lastName;
string firstName;
string phone;
string fax;
string emailAddress;
location address;
vector<contact> contacts;
};
#endif // CLIENT_H
#pragma once
#ifndef CONTACT_H
#define CONTACT_H
#include <string>
using namespace std;
class contact
{
public:
contact();
contact(string, string, string, string);
static int uniqueIdentifier;
private:
int UI;
string firstName;
string lastName;
string phone;
string emailAddress;
};
#endif // CONTACT_H
1つのまったく構造化されていない形式から情報を取得するために多くのコードを必要とするジョブをこの形式にインポートするとき、vector.push_back(temporaryJob)の使用について3つのことに気づきました[実際のコードはjobsDatabase.push_back(tempJob);]
ベクターに追加された5395のジョブに達すると、プログラムは動作を停止し、標準のMicrosoftの「プログラムが応答を停止しました」ウィンドウを表示します。
2番目のベクトルオブジェクトを作成し、最初のベクトルに5000個のオブジェクトが格納されたら、同じエラーが発生する前に2番目のベクトルオブジェクトのサイズが711に達すると追加します。
2つのベクトルオブジェクトに同じコードを使用し、制限を5350に上げると、警告が表示される前に2番目のファイルが474に達します。