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 » Community » Newbie corner » Algorithms and Vectors
Re: Algorithms and Vectors [message #28145 is a reply to message #28142] Wed, 18 August 2010 18:52 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Oh, ok, I see... Well, I don't have right now time to test compiling the code, but I can tell you right away, that you actually don't need this. Find(), FindBinary(), FindUpperBound() etc are doing something little else. They return index where the element should be inserted to keep the array sorted. Check the manual for details.

The simple way to find something, is to just go through the array in for cycle and look for the element you need. For simple struct like yours this should be pretty fast, especially if you check only value of one member.

If you need somewhat complex checking or exact equality of members, I would recommend you using ArrayIndex instead of Array. The only requirement is that you have to implement GetHashValue() function. If I remember correctly that is described quite good in Core Values Tutorial. Then you can search just using myindex.Find(myobject).

Sorry for not giving deeper explanation, I'm in hurry now Smile

Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Open An image upon startup
Next Topic: Assert failed in core/value.h line 464
Goto Forum:
  


Current Time: Sat Jun 21 22:16:18 CEST 2025

Total time taken to generate the page: 0.03954 seconds