Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Implementation of Vector::Add()
Implementation of Vector::Add() [message #52203] Fri, 09 August 2019 04:26 Go to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Vector::Add() (and similar methods) can be implemented via Vector::Add(T&& x=T()). That reduces amount of code.

Similar methods include:

Array::Add()
BiVector::AddHead(), BiVector::AddTail()
AMap::Add(K&& k), Add(const K& k), FindAdd(const K& k), FindAdd(K&& k), Put(const K& k), e.t.c.
ArrayMap::Add(const K& k), Add(K&& k)
FixedAMap::Add(const K& k)

It looks like half of methods of AMap can be eliminated ...

Just my two cents ...


Regards,
Novo
Re: Implementation of Vector::Add() [message #52204 is a reply to message #52203] Fri, 09 August 2019 08:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Fri, 09 August 2019 04:26
Vector::Add() (and similar methods) can be implemented via Vector::Add(T&& x=T()). That reduces amount of code.

Similar methods include:

Array::Add()
BiVector::AddHead(), BiVector::AddTail()
AMap::Add(K&& k), Add(const K& k), FindAdd(const K& k), FindAdd(K&& k), Put(const K& k), e.t.c.
ArrayMap::Add(const K& k), Add(K&& k)
FixedAMap::Add(const K& k)

It looks like half of methods of AMap can be eliminated ...

Just my two cents ...


That AFAIK requires that T has defined move constructor. Add() only requires default constructor.

Mirek
Re: Implementation of Vector::Add() [message #52216 is a reply to message #52204] Fri, 09 August 2019 19:06 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mirek wrote on Fri, 09 August 2019 02:50
That AFAIK requires that T has defined move constructor. Add() only requires default constructor.

Mirek

You are right. I missed this point.


Regards,
Novo
Previous Topic: [SOLVED] Why long long int seems to be 32 bit longer?
Next Topic: Vector< Vector<int> > compilation error
Goto Forum:
  


Current Time: Tue Apr 23 08:03:44 CEST 2024

Total time taken to generate the page: 0.02468 seconds