CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2008
    Posts
    48

    Is it possible to create an Indexing on Linked List

    Hi,
    When comparing Arrays with LinkedList, i observed that, we can doindexing on Arrays which is not possible in case of LinkedList as it does not use the Contigious memory for allocation, so is it possible to overcome this limitation, i mean is it possible to create contigious memroy allocation for linkedlist ?

    Pls clarify me on this.

    Thanks
    Kiran
    Last edited by rsodimbakam; September 17th, 2008 at 11:43 PM.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Is it possible to create an Indexing on Linked List

    No. That would be an array. Linked lists have advantages and disadvantages. What are you trying to do?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Sep 2008
    Posts
    48

    Re: Is it possible to create an Indexing on Linked List

    Hi, i have found that we can use vector present in C++ STL which could help in indexing the linked list.

  4. #4
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: Is it possible to create an Indexing on Linked List

    It's possible, but probably not useful. You want to choose your container based on the ways you need to access it. If you need random access by an index, you probably want an array anyways. If you need insertion and deletion of elements at any position very quickly then a linked list is better. Constructing an index of a linked list gives you the disadvantages of having long insertion/deletion time so you might just as well use a regular array (or vector) in the first place.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured