~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ut0vec.h

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/*******************************************************************//**
20
 
@file include/ut0vec.h
21
 
A vector of pointers to data items
22
 
 
23
 
Created 4/6/2006 Osku Salerma
24
 
************************************************************************/
25
 
 
26
1
#ifndef IB_VECTOR_H
27
2
#define IB_VECTOR_H
28
3
 
29
4
#include "univ.i"
30
5
#include "mem0mem.h"
31
6
 
32
 
/** An automatically resizing vector data type. */
33
7
typedef struct ib_vector_struct ib_vector_t;
34
8
 
35
9
/* An automatically resizing vector datatype with the following properties:
46
20
 relatively small or short-lived uses.
47
21
*/
48
22
 
49
 
/****************************************************************//**
50
 
Create a new vector with the given initial size.
51
 
@return vector */
 
23
/********************************************************************
 
24
Create a new vector with the given initial size. */
52
25
UNIV_INTERN
53
26
ib_vector_t*
54
27
ib_vector_create(
55
28
/*=============*/
56
 
        mem_heap_t*     heap,   /*!< in: heap */
57
 
        ulint           size);  /*!< in: initial size */
 
29
                                /* out: vector */
 
30
        mem_heap_t*     heap,   /* in: heap */
 
31
        ulint           size);  /* in: initial size */
58
32
 
59
 
/****************************************************************//**
 
33
/********************************************************************
60
34
Push a new element to the vector, increasing its size if necessary. */
61
35
UNIV_INTERN
62
36
void
63
37
ib_vector_push(
64
38
/*===========*/
65
 
        ib_vector_t*    vec,    /*!< in: vector */
66
 
        void*           elem);  /*!< in: data element */
 
39
        ib_vector_t*    vec,    /* in: vector */
 
40
        void*           elem);  /* in: data element */
67
41
 
68
 
/****************************************************************//**
69
 
Get the number of elements in the vector.
70
 
@return number of elements in vector */
 
42
/********************************************************************
 
43
Get the number of elements in the vector. */
71
44
UNIV_INLINE
72
45
ulint
73
46
ib_vector_size(
74
47
/*===========*/
75
 
        const ib_vector_t*      vec);   /*!< in: vector */
 
48
                                /* out: number of elements in vector */
 
49
        const ib_vector_t*      vec);   /* in: vector */
76
50
 
77
 
/****************************************************************//**
78
 
Test whether a vector is empty or not.
79
 
@return TRUE if empty */
 
51
/********************************************************************
 
52
Test whether a vector is empty or not. */
80
53
UNIV_INLINE
81
54
ibool
82
55
ib_vector_is_empty(
83
56
/*===============*/
84
 
        const ib_vector_t*      vec);   /*!< in: vector */
 
57
                                /* out: TRUE if empty */
 
58
        const ib_vector_t*      vec);   /* in: vector */
85
59
 
86
 
/****************************************************************//**
87
 
Get the n'th element.
88
 
@return n'th element */
 
60
/********************************************************************
 
61
Get the n'th element. */
89
62
UNIV_INLINE
90
63
void*
91
64
ib_vector_get(
92
65
/*==========*/
93
 
        ib_vector_t*    vec,    /*!< in: vector */
94
 
        ulint           n);     /*!< in: element index to get */
 
66
                                /* out: n'th element */
 
67
        ib_vector_t*    vec,    /* in: vector */
 
68
        ulint           n);     /* in: element index to get */
95
69
 
96
 
/****************************************************************//**
 
70
/********************************************************************
97
71
Remove the last element from the vector. */
98
72
UNIV_INLINE
99
73
void*
100
74
ib_vector_pop(
101
75
/*==========*/
102
 
        ib_vector_t*    vec);   /*!< in: vector */
 
76
        ib_vector_t*    vec);   /* in: vector */
103
77
 
104
 
/****************************************************************//**
 
78
/********************************************************************
105
79
Free the underlying heap of the vector. Note that vec is invalid
106
80
after this call. */
107
81
UNIV_INLINE
108
82
void
109
83
ib_vector_free(
110
84
/*===========*/
111
 
        ib_vector_t*    vec);   /*!< in,own: vector */
 
85
        ib_vector_t*    vec);   /* in,own: vector */
112
86
 
113
 
/** An automatically resizing vector data type. */
 
87
/* See comment at beginning of file. */
114
88
struct ib_vector_struct {
115
 
        mem_heap_t*     heap;   /*!< heap */
116
 
        void**          data;   /*!< data elements */
117
 
        ulint           used;   /*!< number of elements currently used */
118
 
        ulint           total;  /*!< number of elements allocated */
 
89
        mem_heap_t*     heap;   /* heap */
 
90
        void**          data;   /* data elements */
 
91
        ulint           used;   /* number of elements currently used */
 
92
        ulint           total;  /* number of elements allocated */
119
93
};
120
94
 
121
95
#ifndef UNIV_NONINL