![]() ![]() Seems unidiomatic, though, and kind of like "cheating the borrow checker". ![]() This is more focusing on "do it correctly and idiomatically" as opposed to "get the job done", I have already "hacked up" a solution that uses a buffer of Vec, and each Node uses indexes to that vec instead of pointers. Slower access and search times: Access and search operations have O (n) time complexity, where n is the number of elements in the list. Doesn't waste too much space (adjacency matrix doesn't work then, sadly) Disadvantages of Doubly Linked List: More memory usage: Each node in a doubly linked list requires two pointers (previous and next), resulting in higher memory usage compared to a singly linked list.You can easily and quickly move nodes around the graph.I really don't care about any properties except: It's also very sparse, with about 2000 nodes, but each node only being connected to 4-6 other nodes, so the adjacency matrix approach was also out. The graph will be rearranged very often, so I didn't use a vec approach (actually what I want isn't a simple list, so a Vec won't work). I need to keep a "parent" pointer so that each child knows it's parent, hence the doubly linked list. Each node has a Vec of children (it owns its' children) and a pointer to the parent (basically doubly linked list but each node can own multiple subnodes). Both DLL and SLL contain a pointer to the next node, as well as a data field to represent the. What I wanted wasn't a doubly linked list, I just used this question as a way to gain insight to a similar problem (sorry about not putting the "actual" problem there).Īctually what I want isn't really a "doubly linked list", more like a tree where the children have pointers to their parents. A doubly linked list (often abbreviated as DLL) is very much like a regular singly linked list (SLL). ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |