开发者

why does array collection not have splice, copy functions? [duplicate]

开发者 https://www.devze.com 2023-02-14 23:11 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate:开发者_Python百科
This question already has an answer here: Closed 11 years ago.

Possible Duplicate:开发者_Python百科

Why do we not have splice in array collection?

The whole idea behind collection classes is to enhance the basic functionalities of available data structures and wrap them up with useful functions.

Then Why dont I see concat, splice, copy functions in array collections in flex (which are infact available in arrays!). Am I missing something in here or is it like that only?

Will appreciate if someone could enlighten me with the reasons behind this.

Thanks


Technically, a collection can be an unordered list, an associative array, or a tree. However, Adobe's function list is heavily reliant upon indexes, so that's not the reason.

The reason I would say is because the methods you specifically listed don't just destroy sections of the array, the remove it from the original array, create a new array and return it.

A Flex Collection can be linked to remote resources, which helps make it apparent that you couldn't remove items from a DB and create a new DB - you could remove and insert items though.

Also, while an Array Collection is not the same as a Tree Collection, its important that they have the same Interface (setItem, removeItem, etc). Using slice or splice on a tree collection wouldn't work very well.


You'd have more chance of an Adobe engineer answering to the reason on the Adobe community forums.

In my projects, accessing the array inside the arrayCollection to perform those functions hasn't caused any issues. I assume that Adobe's reason is exactly that. The developer still has access to the functionality.

I can see your point though.

0

精彩评论

暂无评论...
验证码 换一张
取 消