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   |
|
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 
Honza
|
|
|
Goto Forum:
Current Time: Sat Jun 21 18:20:53 CEST 2025
Total time taken to generate the page: 0.03296 seconds
|