4 Replies Latest reply on Dec 18, 2007 12:55 PM by binkerboy

    Efficiency of ListCollectionView.getItemIndex(...)

    flexperson
      I need to use: public function getItemIndex(item:Object):int in mx.collections.ListCollectionView and am worried about its efficiency. Will it scale when my collection grows large or is it only suitable for small sized collections?

      I could get my answer if somebody knows how it is implemented under the hood. Do objects have a unique identity that would help facilitate a hash map or a binary search? Or does getItemIndex does as linear scan of the collection?

      Any responses are greatly appreciated! Thanks!
        • 1. Re: Efficiency of ListCollectionView.getItemIndex(...)
          atta707 Level 2
          IUID interface is what you need to implement to provide a unique id for you objects. Once you've done that, as you said, you'll, need to play run certain tests to see how it fares in performance.

          You might want to publish your finding for the forum!

          ATTA
          • 2. Re: Efficiency of ListCollectionView.getItemIndex(...)
            levancho Level 3
            IUID is interesting but I doubt its related to the question, as I understand question is if flex uses hash code to implement collections which is lot more efficient than liniar search,(assuming every object has unique hashcode) I think its more of a ActionScript (ecmascript) question than flex. I doubt there is bucket search support in flex collections but would like to hear from adobe team as well I am also interested, +keeping it alive ..
            • 3. Re: Efficiency of ListCollectionView.getItemIndex(...)
              flexperson Level 1
              Yes, my original question is unanswered. It probably can only be answered by someone who knows the implementation under the hood - probably a member of the Adobe Flex team.

              I am not sure if it is necessarily an Ecmascript/Actionscript questions since I can conceive of an implementation of ListCollectionView that could examine the object's contents, at least partially, and use the information to do better than O(n) operations. On that note, I was thinking perhaps implementing IUID might help the Flex library do better than O(n), but it seems a bit far-fetched.

              In any case, it seems worth the time of somebody from the Flex / ActionScript team to offer some insight into this important issue (since it relates to scale and fundamental aspects of Flex)

              Thanks in advance & thanks for the responses so far.
              • 4. Re: Efficiency of ListCollectionView.getItemIndex(...)
                binkerboy Level 1
                I want to chime in here too, as the answer has relevance for the work I am doing. Anyone know the answer? Thanks.