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 » why not "T & Add(const T & x)" in all containers
Re: why not "T & Add(const T & x)" in all containers [message #29450 is a reply to message #29449] Thu, 21 October 2010 11:54 Go to previous messageGo to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
i thought of it. and there is a solution in the code.
i just split the function, i.e. Set:

original:
	void     Set(int i, const T& x, int count = 1);


split:
	T&       Set(int i, const T& x);
	void     Set(int i, const T& x, int count);

which is syntactically the same, the omited count defaults to setting only one element and returns the ref..no changes in user code. when using count, the other function evaluates.

insert is same:
	void     Insert(int i, const T& x, int count = 1);


split:
	T&       Insert(int i, const T& x);
	void     Insert(int i, const T& x, int count);


i'm actually working with the code for some while now, and haven't noticed any misbehavior, so the sub layers of upp deal well with it. consider it again. i think it can contribute to the comfort using upp containers, and of corse again a little bit of speed optimization at user level..and shorten the code a bit.

attached the current source based snapshot..
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: InitCaps() proposal
Next Topic: Incorrect implementation of INITBLOCK (and similar macros) in case when flagBLITZ is not defined.
Goto Forum:
  


Current Time: Mon Aug 25 02:29:59 CEST 2025

Total time taken to generate the page: 0.00383 seconds