好了,各位,
几个月前,我为其中一个委员会编写了一个数据收集程序,基本上读取了x数量的图形中的所有块,并将信息存储在MS access数据库中。这让我想到,在使用简单迭代将项目与列表中的项目匹配后,是否值得从数组中删除项目。例如
;For the sake of the discussion topic imagine vl-sort doesn't exist(setq BlockList(list [List of block objects from the block table]))(setq modelSpaceBlocks (list [<x> All blocks within modelspace]))(vlax-for BlockListc (setq i -1) (while (< (setq i(1= i))(length modelSpaceBlocks)) (if(equals (vla-getName c)(vla-getName (nth i modelSpaceBlocks)) (progn ;Do something with the block ;-------------------- Include or leave out? -------------- (vl-remove (nth i modelSpaceBlocks) modelSpaceBlocks) ;---------------------------------------------------------- ) ) ))
也许不是最好的例子,但肯定有一个点,其中x的值足够高,以至于每次都要遍历它。在这种情况下,前500个块的删除可能会减慢程序的速度,但随着列表的大小逐渐减小,该过程不会与冗余块进行比较。有人对这个问题有什么想法吗?或者更好的是,有人做过比较吗?
索利弗。