Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutoriallevel2/src/external/enet/list.c @ 8474

Last change on this file since 8474 was 7459, checked in by adrfried, 14 years ago

Merged ipv6 branch

Orxonox now includes a modified version of ENet 1.3.0

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/**
2 @file list.c
3 @brief ENet linked list functions
4*/
5#define ENET_BUILDING_LIB 1
6#include "enet/enet.h"
7
8/**
9    @defgroup list ENet linked list utility functions
10    @ingroup private
11    @{
12*/
13void
14enet_list_clear (ENetList * list)
15{
16   list -> sentinel.next = & list -> sentinel;
17   list -> sentinel.previous = & list -> sentinel;
18}
19
20ENetListIterator
21enet_list_insert (ENetListIterator position, void * data)
22{
23   ENetListIterator result = (ENetListIterator) data;
24
25   result -> previous = position -> previous;
26   result -> next = position;
27
28   result -> previous -> next = result;
29   position -> previous = result;
30
31   return result;
32}
33
34void *
35enet_list_remove (ENetListIterator position)
36{
37   position -> previous -> next = position -> next;
38   position -> next -> previous = position -> previous;
39
40   return position;
41}
42
43ENetListIterator
44enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast)
45{
46   ENetListIterator first = (ENetListIterator) dataFirst,
47                    last = (ENetListIterator) dataLast;
48
49   first -> previous -> next = last -> next;
50   last -> next -> previous = first -> previous;
51
52   first -> previous = position -> previous;
53   last -> next = position;
54
55   first -> previous -> next = first;
56   position -> previous = last;
57   
58   return first;
59}
60
61size_t
62enet_list_size (ENetList * list)
63{
64   size_t size = 0;
65   ENetListIterator position;
66
67   for (position = enet_list_begin (list);
68        position != enet_list_end (list);
69        position = enet_list_next (position))
70     ++ size;
71   
72   return size;
73}
74
75/** @} */
Note: See TracBrowser for help on using the repository browser.