GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Glibc Doubly-Linked Lists Example 'Easy' (C)

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code
Author Message
caracal
GTK+ Guru


Joined: 21 Jun 2007
Posts: 207
Location: Wilkes Barre Pa

PostPosted: Sat Oct 03, 2009 4:53 pm    Post subject: Glibc Doubly-Linked Lists Example 'Easy' (C) Reply with quote

Linked lists are among the simplest and most common data structures, and are used to implement many important abstract data structures, such as stacks, queues, hash tables, symbolic expressions, skip lists, and many more.

The principal benefit of a linked list over a conventional array is that the order of the linked items may be different from the order that the data items are stored in memory or on disk. For that reason, linked lists allow insertion and removal of nodes at any point in the list, with a constant number of operations.
http://en.wikipedia.org/wiki/Linked_list

Doubly-Linked Lists — linked lists containing integer values or pointers to data, with the ability to iterate over the list in both directions
http://library.gnome.org/devel/glib/stable/glib-Doubly-Linked-Lists.html

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#include <glib.h>

/*gcc -Wall -g -o main main.c `pkg-config --cflags --libs glib-2.0`*/

int main(int argc, char** argv)
{
    GList* list = NULL;
    list = g_list_append(list, "Hello World!");

    g_print("The first item is '%s' \n", (char *)g_list_first(list)->data);
    g_list_free(list);
    return 0;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP