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 » FEATURE: T* ArrayIndex::Detach(int i) AND mini fix
FEATURE: T* ArrayIndex::Detach(int i) AND mini fix [message #26295] Thu, 22 April 2010 11:06 Go to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
the Detach function available in Array:: and ArrayMap (recently added) should be added to ArrayIndex as well, right?

Index.h:229 should be added sth like

	T        *PopDetach()                           { B::hash.Drop(1); return B::key.PopDetach(); }
	T        *Detach(int i)                         { B::hash.Remove(i); return B::key.Detach(i); }


and a mini fix: (maybe forgotten? standard param)

Index.h:52 should be
	void  Drop(int n = 1);
Re: FEATURE: T* ArrayIndex::Detach(int i) AND mini fix [message #26337 is a reply to message #26295] Mon, 26 April 2010 10:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 22 April 2010 05:06

the Detach function available in Array:: and ArrayMap (recently added) should be added to ArrayIndex as well, right?

Index.h:229 should be added sth like

	T        *PopDetach()                           { B::hash.Drop(1); return B::key.PopDetach(); }
	T        *Detach(int i)                         { B::hash.Remove(i); return B::key.Detach(i); }




Well, why not, applied.

Frankly, IndexArray is provided just for completeness. I do not remember using it ever... Smile It so happens that all potential keys tend to be moveable... (in fact, 98% of keys is either int or String anyway).

Quote:


and a mini fix: (maybe forgotten? standard param)

Index.h:52 should be
	void  Drop(int n = 1);



Well, HashBase is just implementation issue that is not supposed to be used on its own... So its interface is irrelevant from client's perspective.

Mirek
Re: FEATURE: T* ArrayIndex::Detach(int i) AND mini fix [message #26350 is a reply to message #26337] Mon, 26 April 2010 17:50 Go to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
same with me, i havent used ArrayIndex so far. in a recent case i was in need to have kind of a "dictionary" of data objects, which have their own GetHashValue, so i wanted to see if ArrayIndex is my coice to avoid ArrayMap usage like to save some writing.

OBJECT * obj; 
... 
amap.Add(obj->GetHashValue(), obj);


rather like this
OBJECT * obj;
...
ind.Add(obj);


but realized i have no means to provide a hash on its own, so i stayed with ArrayMap. and by the way had a bit of investigation of API. frankly, i really like the containers Smile
Previous Topic: WHY? "Index:: and ArrayIndex::operator[]" returns const T&
Next Topic: _pick understanding
Goto Forum:
  


Current Time: Mon Apr 29 00:42:15 CEST 2024

Total time taken to generate the page: 0.02343 seconds