number of elements in double linked list

This is a discussion on number of elements in double linked list within the C++ Programming forums, part of the General Programming Boards category; hi how can i find the number of elements in double linked list. thank u sree...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    90

    number of elements in double linked list

    hi how can i find the number of elements in double linked list.
    thank u
    sree

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by cnu_sree View Post
    hi how can i find the number of elements in double linked list.
    thank u
    sree
    Count them.

    I don't think most doubly-linked list implementations keep a counter around, so walk the list and count as you go.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    90
    no function like queue
    in queue we have
    queue.size()
    so wht about for double linked list

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you're using std::list, then yes there's a .size() function.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    when you create header node for doubly linked list that time keep counter in header node so whenever you add nodes to list then simply increment counter in header node then that header node information will give you number of nodes in list
    Last edited by vinod_mrd; 01-25-2008 at 11:19 AM. Reason: spelling mistake

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Double Linked List Problem
    By Shiggins in forum C++ Programming
    Replies: 4
    Last Post: 03-10-2009, 07:15 AM
  2. Need help sorting a linked list. Beginner
    By scarlet00014 in forum C Programming
    Replies: 1
    Last Post: 09-27-2008, 06:16 PM
  3. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 12:21 PM
  4. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  5. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21