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

This is a discussion on How to move up or down Item in List using C and GList (Doubly-Linked Lists) code within the C Programming forums, part of the General Programming Boards category; How to move up or down Item in List using C and GList (Doubly-Linked Lists) code In abstraction I know ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,425
    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, 12: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, 02:26 PM

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