Is there a way to pass a value to a flex ArrayCollection and check whether it exists there or not. I mean, I want to insert values to a Flex Array but before that, i need to check if it already exists or not. Let me know if we can do this without looping through the ArrayCollection which i found as a bottleneck if the length of the ArrayCollection is high
Asked
Active
Viewed 5,290 times
2 Answers
1
Just check the API docs: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/ArrayCollection.html
ArrayCollection#getItemIndex is what you want.

Creynders
- 4,573
- 20
- 21
0
ArrayCollection has a "contains" method that you can use for this.
Note that if you really want to search fast, I would suggest that you create a lookup table or implement a binary search if your collection is always sorted.

Christophe Herreman
- 15,895
- 9
- 58
- 86
-
1thanks for the reply.as far as I know contains() method checks for the object's existence comparing references. This always returned false for me – sher17 Jun 09 '13 at 08:07
-
That is correct. If your objects are different instances you'll need to implement a search function yourself. – Christophe Herreman Jun 09 '13 at 08:43