Thread: How to move up or down Item in List using C and GList (Doubly-Linked Lists) code

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    8

    How to move up or down Item in List using C and GList (Doubly-Linked Lists) code

    How to move up or down Item in List using C and GList (Doubly-Linked Lists) code

    In abstraction I know what should be done, but in practice not handle it.

    For down button:

    When select a List Item click on Move Down
    That time get the Current Index of the Selected List Item
    Then remove the item from the Selected Index
    And add the same Item object by Insert with Previous Selected Index + 1

    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    So you have a doubly linked list, say

    1 <-> 2 <-> 3 <-> 4 <-> 5

    And if you were pointing at 3, to move it down one place, you would end up with

    1 <-> 2 <-> 4 <-> 3 <-> 5
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubly linked lists
    By mohanlon in forum C Programming
    Replies: 8
    Last Post: 12-08-2010, 01:01 AM
  2. Doubly Linked Lists
    By tsut in forum C++ Programming
    Replies: 3
    Last Post: 09-26-2003, 07:53 AM
  3. doubly linked lists
    By AmazingRando in forum C Programming
    Replies: 4
    Last Post: 09-21-2003, 01:57 PM
  4. doubly linked lists
    By cworld in forum C++ Programming
    Replies: 2
    Last Post: 04-21-2002, 09:33 AM
  5. Doubly Linked Lists
    By lenicush in forum C Programming
    Replies: 6
    Last Post: 11-17-2001, 03:26 PM