开发者

Flash: runtime complexity of the 'Sprite.contains'?

开发者 https://www.devze.com 2023-01-05 07:38 出处:网络
As the title suggests, what is 开发者_开发技巧the runtime complexity (eg, big-O) of the Sprite.contains method?According to the documentation, it\'s available in any version of Flash Player 9. Have yo

As the title suggests, what is 开发者_开发技巧the runtime complexity (eg, big-O) of the Sprite.contains method?


According to the documentation, it's available in any version of Flash Player 9. Have you seen something to indicate otherwise?


I don't have an authoritative answer, but anything other than O(n) would surprise me. It should be a simple walk down the display list, with a simple pointer comparison at each stop.

Should be fast, but it would probably be even faster (depending on the actual display list) to query possible childs parent atribute (with recursion up the parent chain up to to the display list root node) and look if the potential parent sprite is there.

Sprite.getChildByName() is a decidedly worse alternative.

0

精彩评论

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