blob: 4a2bd720317e9fd04bdd5e303479196f62224afa [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* List object interface */
2
3/*
4123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
5
6Another generally useful object type is an list of object pointers.
7This is a mutable type: the list items can be changed, and items can be
8added or removed. Out-of-range indices or non-list objects are ignored.
9
10*** WARNING *** setlistitem does not increment the new item's reference
11count, but does decrement the reference count of the item it replaces,
12if not nil. It does *decrement* the reference count if it is *not*
13inserted in the list. Similarly, getlistitem does not increment the
14returned item's reference count.
15*/
16
Guido van Rossum3f5da241990-12-20 15:06:42 +000017typedef struct {
18 OB_VARHEAD
19 object **ob_item;
20} listobject;
21
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022extern typeobject Listtype;
23
24#define is_listobject(op) ((op)->ob_type == &Listtype)
25
26extern object *newlistobject PROTO((int size));
27extern int getlistsize PROTO((object *));
28extern object *getlistitem PROTO((object *, int));
29extern int setlistitem PROTO((object *, int, object *));
30extern int inslistitem PROTO((object *, int, object *));
31extern int addlistitem PROTO((object *, object *));
Guido van Rossum14da5801990-10-30 13:32:39 +000032extern int sortlist PROTO((object *));
Guido van Rossum3f5da241990-12-20 15:06:42 +000033
34/* Macro, trading safety for speed */
35#define GETLISTITEM(op, i) ((op)->ob_item[i])