It must be possible to traverse a list removing elements and adding some new to the begining in an efficient fashion. In C I would use a linked list,
Asked
Active
Viewed 391 times
-2
-
1Do you mean [collections.deque](http://docs.python.org/library/collections.html#collections.deque)? – jfs Jul 28 '12 at 23:09
-
3Yes - it is possible. What have you tried so far? – Jon Clements Jul 28 '12 at 23:18
-
Yes I mean collections.deque. I want go through it element delete some and add occasionally some to the beginning. – warsaga Jul 29 '12 at 19:49
1 Answers
1
There are plenty of examples of LinkedList implementations in Python. I came across a good one in SO a while back... Python Linked List. If you scroll down a bit, some other users have some good implementations to follow.
-
That's assuming you want to stick to a LinkedList. But of course, your question is very broad, you can find a different way as well. – KVISH Jul 28 '12 at 23:11
-
-
1Deque is almost what I was looking for, but how can you traverse it, with a sort of iterator. I have to perfom a complex calculation before I decide to keep an element. – warsaga Jul 29 '12 at 08:04