Flex 3 Actionscript 数组减法函数
谁能告诉我如何比较两个数组并删除 ActionScript 中的常用术语?
例如:
Array1 = [2,4,6,8,10,12]
Array2 = [1,2,3,4,5,6,7,8,9,10,11]
Array1 - Array2 = [12]
Can anyone tell me how to compare two arrays and delete the common terms in ActionScript?
Eg:
Array1 = [2,4,6,8,10,12]
Array2 = [1,2,3,4,5,6,7,8,9,10,11]
Array1 - Array2 = [12]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用 ActionLinq,则可以很容易地进行如下集合数学运算:
If you use ActionLinq, it is very easy to do set mathematics like this:
您可以使用自定义函数进行过滤。
这不是过滤数组差异的优化方法,但它可以完成工作。
You can filter using a custom function.
This is not an optimized way of filtering a difference of arrays, but it'll get the job done.
如果您希望从数组中删除所有重复项,那么我建议您使用 Set 来使查找速度尽可能快:
如果您发现自己在集合方面做了很多工作,那么我建议您投资一个集合框架例如 AS3Commons 集合。
If you wish to knock out all duplicates from an Array then I suggest that you use a Set to make the lookup speed as fast as possible:
If you find yourself doing a lot of work with collections then I would advise you invest in a Collections Framework such as AS3Commons Collections.