Use c.push_back instead of c.insert(c.end,...)

pull/110/head
Hleb Valoshka 2018-08-02 16:18:35 +03:00
parent f9d096d6da
commit 27e39aa4c3
23 changed files with 54 additions and 59 deletions

View File

@ -786,7 +786,7 @@ bool ReadStarRecord(istream& in)
cout << "Huge BTmag error for HIP " << star.HIPCatalogNumber << " from Line " << lineno << " ." << endl;
}
stars.insert(stars.end(), star);
stars.push_back(star);
return true;
}
@ -873,7 +873,7 @@ bool ReadComponentRecord(istream& in)
}
}
components.insert(components.end(), component);
components.push_back(component);
return true;
};
@ -985,7 +985,7 @@ void CreateCompanionList()
star.CCDMIdentifier = comp.star->CCDMIdentifier;
star.parallaxError = comp.star->parallaxError;
companions.insert(companions.end(), star);
companions.push_back(star);
}
}
}
@ -1116,7 +1116,7 @@ int main(int argc, char* argv[])
cout << "Read " << stars.size() << " stars from main database.\n";
cout << "Adding the Sun...\n";
}
stars.insert(stars.end(), TheSun());
stars.push_back(TheSun());
if (verbose>=0)
cout << "Sorting stars...\n";
@ -1124,7 +1124,7 @@ int main(int argc, char* argv[])
starIndex.reserve(stars.size());
for (const auto& star : stars)
{
starIndex.insert(starIndex.end(), &star);
starIndex.push_back(&star);
}
HIPCatalogComparePredicate pred;

View File

@ -156,9 +156,9 @@ uint16_t M3DTriangleMesh::getFaceCount() const
void M3DTriangleMesh::addFace(uint16_t v0, uint16_t v1, uint16_t v2)
{
faces.insert(faces.end(), v0);
faces.insert(faces.end(), v1);
faces.insert(faces.end(), v2);
faces.push_back(v0);
faces.push_back(v1);
faces.push_back(v2);
}
uint32_t M3DTriangleMesh::getSmoothingGroups(uint16_t face) const
@ -168,7 +168,7 @@ uint32_t M3DTriangleMesh::getSmoothingGroups(uint16_t face) const
void M3DTriangleMesh::addSmoothingGroups(uint32_t smGroups)
{
smoothingGroups.insert(smoothingGroups.end(), smGroups);
smoothingGroups.push_back(smGroups);
}
uint16_t M3DTriangleMesh::getSmoothingGroupCount() const
@ -210,7 +210,7 @@ uint32_t M3DModel::getTriMeshCount()
void M3DModel::addTriMesh(M3DTriangleMesh* triMesh)
{
triMeshes.insert(triMeshes.end(), triMesh);
triMeshes.push_back(triMesh);
}
void M3DModel::setName(const string& _name)
@ -244,7 +244,7 @@ uint32_t M3DScene::getModelCount() const
void M3DScene::addModel(M3DModel* model)
{
models.insert(models.end(), model);
models.push_back(model);
}
M3DMaterial* M3DScene::getMaterial(uint32_t n) const
@ -259,7 +259,7 @@ uint32_t M3DScene::getMaterialCount() const
void M3DScene::addMaterial(M3DMaterial* material)
{
materials.insert(materials.end(), material);
materials.push_back(material);
}
M3DColor M3DScene::getBackgroundColor() const

View File

@ -46,7 +46,7 @@ const Asterism::Chain& Asterism::getChain(int index) const
void Asterism::addChain(Asterism::Chain& chain)
{
chains.insert(chains.end(), &chain);
chains.push_back(&chain);
}
@ -156,7 +156,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
}
}
asterisms->insert(asterisms->end(), ast);
asterisms->push_back(ast);
delete chainsValue;
}

View File

@ -805,9 +805,7 @@ vector<string>* Body::getAlternateSurfaceNames() const
if (altSurfaces)
{
for (const auto& s : *altSurfaces)
{
names->insert(names->end(), s.first);
}
names->push_back(s.first);
}
return names;
@ -822,7 +820,7 @@ void Body::addLocation(Location* loc)
if (!locations)
locations = new vector<Location*>();
locations->insert(locations->end(), loc);
locations->push_back(loc);
loc->setParentBody(this);
}
@ -1111,7 +1109,7 @@ void PlanetarySystem::removeAlias(const Body* body, const string& alias)
void PlanetarySystem::addBody(Body* body)
{
satellites.insert(satellites.end(), body);
satellites.push_back(body);
addBodyToNameIndex(body);
}

View File

@ -43,9 +43,9 @@ void ConstellationBoundaries::moveto(float ra, float dec)
Vector3f v = astro::equatorialToEclipticCartesian(ra, dec, BoundariesDrawDistance);
if (currentChain->size() > 1)
{
chains.insert(chains.end(), currentChain);
chains.push_back(currentChain);
currentChain = new Chain();
currentChain->insert(currentChain->end(), v);
currentChain->push_back(v);
}
else
{

View File

@ -113,7 +113,7 @@ void CatalogCrossReference::addEntry(uint32_t catalogNumber, Star* star)
e.catalogNumber = catalogNumber;
e.star = star;
entries.insert(entries.end(), e);
entries.push_back(e);
}
void CatalogCrossReference::sortEntries()

View File

@ -84,7 +84,7 @@ CommandSequence* CommandParser::parse()
}
else
{
seq->insert(seq->end(), cmd);
seq->push_back(cmd);
}
ttype = tokenizer->nextToken();
@ -110,7 +110,7 @@ const vector<string>* CommandParser::getErrors() const
void CommandParser::error(const string errMsg)
{
errorList.insert(errorList.end(), errMsg);
errorList.push_back(errMsg);
}

View File

@ -37,7 +37,7 @@ void GLContext::init(const vector<string>& ignoreExt)
// scan the ignore list
auto iter = std::find(ignoreExt.begin(), ignoreExt.end(), ext);
if (iter == ignoreExt.end())
extensions.insert(extensions.end(), ext);
extensions.push_back(ext);
if (*next == '\0')
break;

View File

@ -136,7 +136,7 @@ ValueArray* Parser::readArray()
Value* v = readValue();
while (v != nullptr)
{
array->insert(array->end(), v);
array->push_back(v);
v = readValue();
}

View File

@ -9083,7 +9083,7 @@ void StarRenderer::process(const Star& star, float distance, float appMag)
}
p.color = Color(starColor, alpha);
glareParticles->insert(glareParticles->end(), p);
glareParticles->push_back(p);
++nBright;
}
}
@ -9331,7 +9331,7 @@ void PointStarRenderer::process(const Star& star, float distance, float appMag)
rle.discSizeInPixels = discSizeInPixels;
rle.appMag = appMag;
rle.isOpaque = true;
renderList->insert(renderList->end(), rle);
renderList->push_back(rle);
}
}
}
@ -10594,7 +10594,7 @@ void Renderer::markSettingsChanged()
void Renderer::addWatcher(RendererWatcher* watcher)
{
assert(watcher != nullptr);
watchers.insert(watchers.end(), watcher);
watchers.push_back(watcher);
}

View File

@ -22,7 +22,7 @@ Simulation::Simulation(Universe* _universe) :
universe(_universe)
{
activeObserver = new Observer();
observers.insert(observers.end(), activeObserver);
observers.push_back(activeObserver);
}
@ -172,7 +172,7 @@ Observer& Simulation::getObserver()
Observer* Simulation::addObserver()
{
Observer* o = new Observer();
observers.insert(observers.end(), o);
observers.push_back(o);
return o;
}

View File

@ -141,7 +141,7 @@ findStars(const StarDatabase& stardb, Pred pred, int nStars)
// Move the best matching stars into the vector
finalStars->reserve(nStars);
for (const auto& star : firstStars)
finalStars->insert(finalStars->end(), star);
finalStars->push_back(star);
return finalStars;
}

View File

@ -604,7 +604,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
return false;
}
xindex->insert(xindex->end(), ent);
xindex->push_back(ent);
record++;
}

View File

@ -188,7 +188,7 @@ void Universe::markObject(const Selection& sel,
marker.setPriority(priority);
marker.setOccludable(occludable);
marker.setSizing(sizing);
markers->insert(markers->end(), marker);
markers->push_back(marker);
}

View File

@ -109,7 +109,7 @@ template <typename T> void SampledOrbit<T>::addSample(double t, double x, double
samp.y = (T) y;
samp.z = (T) z;
samp.t = t;
samples.insert(samples.end(), samp);
samples.push_back(samp);
}
template <typename T> double SampledOrbit<T>::getPeriod() const

View File

@ -2620,8 +2620,8 @@ void CelestiaCore::splitView(View::Type type, View* av, float splitPos)
view->parent = split;
view->zoom = av->zoom;
views.insert(views.end(), split);
views.insert(views.end(), view);
views.push_back(split);
views.push_back(view);
setFOVFromZoom();
}
@ -4292,7 +4292,7 @@ bool CelestiaCore::initSimulation(const string* configFileName,
sim->setFaintestVisible(config->faintestVisible);
View* view = new View(View::ViewWindow, sim->getActiveObserver(), 0.0f, 0.0f, 1.0f, 1.0f);
views.insert(views.end(), view);
views.push_back(view);
activeView = views.begin();
if (!compareIgnoringCase(getConfig()->cursor, "inverting crosshair"))
@ -4750,7 +4750,7 @@ CelestiaConfig* CelestiaCore::getConfig() const
void CelestiaCore::addWatcher(CelestiaWatcher* watcher)
{
assert(watcher != nullptr);
watchers.insert(watchers.end(), watcher);
watchers.push_back(watcher);
}
void CelestiaCore::removeWatcher(CelestiaWatcher* watcher)

View File

@ -155,8 +155,7 @@ CelestiaConfig* ReadCelestiaConfig(const string& filename, CelestiaConfig *confi
// assert(catalogNameVal != nullptr);
if (catalogNameVal->getType() == Value::StringType)
{
config->solarSystemFiles.insert(config->solarSystemFiles.end(),
WordExp(catalogNameVal->getString()));
config->solarSystemFiles.push_back(WordExp(catalogNameVal->getString()));
}
else
{
@ -239,8 +238,7 @@ CelestiaConfig* ReadCelestiaConfig(const string& filename, CelestiaConfig *confi
{
if (dirNameVal->getType() == Value::StringType)
{
config->extrasDirs.insert(config->extrasDirs.end(),
WordExp(dirNameVal->getString()));
config->extrasDirs.push_back(WordExp(dirNameVal->getString()));
}
else
{
@ -251,8 +249,7 @@ CelestiaConfig* ReadCelestiaConfig(const string& filename, CelestiaConfig *confi
}
else if (extrasDirsVal->getType() == Value::StringType)
{
config->extrasDirs.insert(config->extrasDirs.end(),
WordExp(extrasDirsVal->getString()));
config->extrasDirs.push_back(WordExp(extrasDirsVal->getString()));
}
else
{

View File

@ -70,7 +70,7 @@ DestinationList* ReadDestinationList(istream& in)
dest->distance = astro::AUtoLightYears(dest->distance);
}
destinations->insert(destinations->end(), dest);
destinations->push_back(dest);
}
delete destValue;

View File

@ -135,7 +135,7 @@ int EclipseFinder::CalculateEclipses()
{
eclipse = new Eclipse(0.);
eclipse->planete = "None";
Eclipses_.insert(Eclipses_.end(), *eclipse);
Eclipses_.push_back(*eclipse);
delete eclipse;
return 1;
}
@ -143,7 +143,7 @@ int EclipseFinder::CalculateEclipses()
{
eclipse = new Eclipse(0.);
eclipse->planete = "None";
Eclipses_.insert(Eclipses_.end(), *eclipse);
Eclipses_.push_back(*eclipse);
delete eclipse;
return 1;
}
@ -210,7 +210,7 @@ int EclipseFinder::CalculateEclipses()
eclipse->body = receiver;
eclipse->planete = planete->getName();
eclipse->sattelite = satellites->getBody(j)->getName();
Eclipses_.insert(Eclipses_.end(), *eclipse);
Eclipses_.push_back(*eclipse);
delete eclipse;
}
}
@ -222,7 +222,7 @@ int EclipseFinder::CalculateEclipses()
{
eclipse = new Eclipse(0.);
eclipse->planete = "None";
Eclipses_.insert(Eclipses_.end(), *eclipse);
Eclipses_.push_back(*eclipse);
delete eclipse;
}
return 0;

View File

@ -58,7 +58,7 @@ FavoritesList* ReadFavoritesList(istream& in)
fav->isFolder = false;
if(fav->isFolder)
{
favorites->insert(favorites->end(), fav);
favorites->push_back(fav);
continue;
}
@ -106,7 +106,7 @@ FavoritesList* ReadFavoritesList(istream& in)
else
fav->coordSys = ObserverFrame::Universal;
favorites->insert(favorites->end(), fav);
favorites->push_back(fav);
}
return favorites;

View File

@ -204,7 +204,7 @@ void TextureFont::bind()
void TextureFont::addGlyph(const TextureFont::Glyph& g)
{
glyphs.insert(glyphs.end(), g);
glyphs.push_back(g);
if (g.width > maxWidth)
maxWidth = g.width;
}

View File

@ -74,7 +74,7 @@ template<class T> class ResourceManager
else
{
ResourceHandle h = handles.size();
resources.insert(resources.end(), info);
resources.push_back(info);
handles.insert(ResourceHandleMapValue(info, h));
return h;
}

View File

@ -396,7 +396,7 @@ bool ReadStarRecord(istream& in)
star.parallaxError = (int8_t) (parallaxError / star.parallax * 200);
}
stars.insert(stars.end(), star);
stars.push_back(star);
return true;
}
@ -483,7 +483,7 @@ bool ReadComponentRecord(istream& in)
}
}
components.insert(components.end(), component);
components.push_back(component);
return true;
};
@ -653,7 +653,7 @@ void CreateCompanionList()
star.CCDMIdentifier = iter->star->CCDMIdentifier;
star.parallaxError = iter->star->parallaxError;
companions.insert(companions.end(), star);
companions.push_back(star);
}
}
}
@ -703,7 +703,7 @@ int main(int argc, char* argv[])
cout << "Read " << stars.size() << " stars from main database.\n";
cout << "Adding the Sun...\n";
stars.insert(stars.end(), TheSun());
stars.push_back(TheSun());
cout << "Sorting stars...\n";
{
@ -711,7 +711,7 @@ int main(int argc, char* argv[])
for (vector<HipparcosStar>::iterator iter = stars.begin();
iter != stars.end(); iter++)
{
starIndex.insert(starIndex.end(), iter);
starIndex.push_back(iter);
}
HIPCatalogComparePredicate pred;