~ubuntu-branches/ubuntu/precise/supertuxkart/precise

« back to all changes in this revision

Viewing changes to src/enet/list.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-24 22:36:25 UTC
  • mfrom: (1.1.9 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110224223625-ygrjfpg92obovuch
Tags: 0.7+dfsg1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** 
2
 
 @file list.c
3
 
 @brief ENet linked list functions
4
 
*/
5
 
#define ENET_BUILDING_LIB 1
6
 
#include "enet/list.h"
7
 
 
8
 
/** 
9
 
    @defgroup list ENet linked list utility functions
10
 
    @ingroup private
11
 
    @{
12
 
*/
13
 
void
14
 
enet_list_clear (ENetList * list)
15
 
{
16
 
   list -> sentinel.next = & list -> sentinel;
17
 
   list -> sentinel.previous = & list -> sentinel;
18
 
}
19
 
 
20
 
ENetListIterator
21
 
enet_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
 
 
34
 
void *
35
 
enet_list_remove (ENetListIterator position)
36
 
{
37
 
   position -> previous -> next = position -> next;
38
 
   position -> next -> previous = position -> previous;
39
 
 
40
 
   return position;
41
 
}
42
 
 
43
 
size_t
44
 
enet_list_size (ENetList * list)
45
 
{
46
 
   size_t size = 0;
47
 
   ENetListIterator position;
48
 
 
49
 
   for (position = enet_list_begin (list);
50
 
        position != enet_list_end (list);
51
 
        position = enet_list_next (position))
52
 
     ++ size;
53
 
   
54
 
   return size;
55
 
}
56
 
 
57
 
/** @} */