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++ Callbacks and Timers » "Suicide Buttons Array" or how to re-index callbacks or...?
Re: "Suicide Buttons Array" or how to re-index callbacks or...? [message #3517 is a reply to message #3504] Tue, 30 May 2006 23:42 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 29 May 2006 14:01

P.S. Or what could be a more effective way than:
	void ReIndex(){
		for(int i=0;i<buts.GetCount();i++){
			buts[i].SetLabel(AsString(i));
			buts[i].WhenAction=callback1(this,Suicide,i);
		}
.S. Or what could be a more effective way than:
<CODE]
void ReIndex(){
for(int i=0;i<buts.GetCount();i++){
buts[i].SetLabel(AsString(i));
buts[i].WhenAction=callback1(this,Suicide,i);
}
</CODE
every time after removing?
Or maybe to mark them as dead and then to filter actions everywhere else?
Are there any better ways?




Well, I believe this is not very callback-specific... it is simply the problem of unique identification of item in the array...

Solution depends on what you exactly want to achieve. What you propose is not that bad solution - if you NEED index, I see (at the moment) no other algorithmic way.

Alternative solution would have to introduce another form of unique id per button - e.g. you could post pointer to button instead of index, or you could use UUID and Index....

Mirek
 
Read Message
Read Message
Read Message
Previous Topic: what KillPostCallback is suppose to do
Next Topic: Question about PostCallback from Child Thread
Goto Forum:
  


Current Time: Sun Apr 28 14:42:02 CEST 2024

Total time taken to generate the page: 0.12176 seconds