Results 1 to 5 of 5

Thread: circular linked lists

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    circular linked lists

    Hello

    I have been programming stacks and queues, and wondering if it is possible to program a circular queue.

    What problems could happen?

    Steve
    steve

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    circular queues are most useful if their size is constant, nearly constant or don't run over certain limit. If it becomes full you need to resize it, and thats about the only concern with it, a size of power of two is ideal because then you can use the bitwise and operator to wrap around head and tail (modulus is slow and shouldn't be used, alternatively you can use ifs)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Hypothetically, if I created a circular list in Managed C++ and then lost my last external pointer to the 'ring' (but the list was still intact in memory) would the GC try to collect back the memory at the end of the program or would the ring stay in RAM until system shutdown?
    I don't live here any more.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    GCs detect rings and remove them if they're orphaned.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Cool!
    I don't live here any more.

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