Is a Linked-List implementation without using pointers possible or not?

前端 未结 14 1547
再見小時候
再見小時候 2020-12-01 07:57

My question is very simple, can one using C++, implement a link-list data structure without using pointers (next nodes)? To further qualify my question, I\'m mean can one cr

14条回答
  •  醉梦人生
    2020-12-01 08:38

    While I'm not sure just what the context behind your question is, if you do a little out of the box thinking I'm sure you can.

    DVK suggested arrays, which is quite true, but arrays are simply thin wrappers around pointer arithmetic.

    How about something entirely different: use the filesystem to do the storage for you!

    for example, the file /linked-list/1 contains the data:

    Data 1!

    5

    and /linked-list/5 is the next node in the list...

    If you're willing to hack enough, anything is possible :-p

    Note that said implementation's complexity / speed is entirely dependent on your filesystem (i.e. it's not necessarily O(1) for everything)

提交回复
热议问题