TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
List.h
Go to the documentation of this file.
1/* -*- Mode: C++; -*- */
2/* VER: $Id$ */
3// copyright (c) 2004 by Christos Dimitrakakis <dimitrak@idiap.ch>
4/***************************************************************************
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 ***************************************************************************/
12#ifndef LIST_H
13#define LIST_H
14
15#include <stdlib.h>
16#include <stdio.h>
17#include <assert.h>
18
20typedef struct ListItem {
21 void* obj;
22 void (*free_obj) (void* obj);
23 struct ListItem* prev;
24 struct ListItem* next;
26
27
37typedef struct List {
41 int n;
43 LISTITEM* (*retrieve) (struct List* list, void* ptr);
45
46
48LIST* List(void);
50int ListSize(LIST* list);
52LISTITEM* ListAppend(LIST* list, void* p);
54LISTITEM* ListAppend(LIST* list, void* p, void (*free_obj) (void* obj));
62int PopItem(LIST* list);
64int ClearList(LIST* list);
66LISTITEM* FindItem (LIST* list, void* ptr);
68LISTITEM* GetItem (LIST* list, int n);
69
70LISTITEM* ListItem(void* ptr, void (*free_obj) (void* obj));
73LISTITEM* LinkNext(LISTITEM* src, void* ptr, void (*free_obj) (void* obj));
74LISTITEM* LinkPrev(LISTITEM* src, void* ptr, void (*free_obj) (void* obj));
75int FreeListItem(LIST* list, LISTITEM* ptr);
76int RemoveListItem(LIST* list, LISTITEM* ptr);
77
78LISTITEM* ListLinearSearchRetrieve (struct List* list, void* ptr);
79
80#endif
static Point p[4]
Definition Convex.cpp:54
LISTITEM * FirstListItem(LIST *list)
Move to the first list item.
Definition List.cpp:81
LIST * List(void)
Create a new list.
Definition List.cpp:16
LISTITEM * ListLinearSearchRetrieve(struct List *list, void *ptr)
Definition List.cpp:324
LISTITEM * ListAppend(LIST *list, void *p)
Append an item to the list.
Definition List.cpp:34
LISTITEM * GetItem(LIST *list, int n)
Get the nth item of the list.
Definition List.cpp:345
LISTITEM * LinkNext(LISTITEM *src, void *ptr, void(*free_obj)(void *obj))
Definition List.cpp:136
int RemoveListItem(LIST *list, LISTITEM *ptr)
Definition List.cpp:201
LISTITEM * GetNextItem(LISTITEM *ptr)
Definition List.cpp:115
LISTITEM * LinkPrev(LISTITEM *src, void *ptr, void(*free_obj)(void *obj))
Definition List.cpp:158
int FreeListItem(LIST *list, LISTITEM *ptr)
Definition List.cpp:182
LISTITEM * FindItem(LIST *list, void *ptr)
Finds the LISTITEM pointer corresponding to the data.
Definition List.cpp:318
struct ListItem LISTITEM
A list item.
LISTITEM * LastListItem(LIST *list)
Move to the last list item.
Definition List.cpp:98
int ListSize(LIST *list)
Get the size of the list.
Definition List.cpp:341
int ClearList(LIST *list)
Clear the list.
Definition List.cpp:291
int PopItem(LIST *list)
Remove the topmost item of the list (also frees obj memory)
Definition List.cpp:252
struct List LIST
A very simple list structure.
LISTITEM * NextListItem(LIST *list)
Advance one item.
Definition List.cpp:67
LISTITEM * GetPrevItem(LISTITEM *ptr)
Definition List.cpp:126
LISTITEM * ListItem(void *ptr, void(*free_obj)(void *obj))
Definition List.cpp:164
A very simple list structure.
Definition List.h:37
LISTITEM * head
head item
Definition List.h:39
LISTITEM * curr
current item
Definition List.h:38
LISTITEM * tail
tail item
Definition List.h:40
int n
number of items
Definition List.h:41
A list item.
Definition List.h:20
struct ListItem * next
next item
Definition List.h:24
void * obj
data
Definition List.h:21
void(* free_obj)(void *obj)
free hook
Definition List.h:22
struct ListItem * prev
previous item
Definition List.h:23