1
by brian
clean slate |
1 |
/**********************************************************************
|
2 |
File-based list utilities
|
|
3 |
||
4 |
(c) 1995 Innobase Oy
|
|
5 |
||
6 |
Created 11/28/1995 Heikki Tuuri
|
|
7 |
***********************************************************************/
|
|
8 |
||
9 |
#ifndef fut0lst_h
|
|
10 |
#define fut0lst_h
|
|
11 |
||
12 |
#include "univ.i" |
|
13 |
||
14 |
#include "fil0fil.h" |
|
15 |
#include "mtr0mtr.h" |
|
16 |
||
17 |
||
18 |
/* The C 'types' of base node and list node: these should be used to
|
|
19 |
write self-documenting code. Of course, the sizeof macro cannot be
|
|
20 |
applied to these types! */
|
|
21 |
||
22 |
typedef byte flst_base_node_t; |
|
23 |
typedef byte flst_node_t; |
|
24 |
||
25 |
/* The physical size of a list base node in bytes */
|
|
26 |
#define FLST_BASE_NODE_SIZE (4 + 2 * FIL_ADDR_SIZE)
|
|
27 |
||
28 |
/* The physical size of a list node in bytes */
|
|
29 |
#define FLST_NODE_SIZE (2 * FIL_ADDR_SIZE)
|
|
30 |
||
31 |
||
32 |
/************************************************************************
|
|
33 |
Initializes a list base node. */
|
|
34 |
UNIV_INLINE
|
|
35 |
void
|
|
36 |
flst_init( |
|
37 |
/*======*/
|
|
38 |
flst_base_node_t* base, /* in: pointer to base node */ |
|
39 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
40 |
/************************************************************************
|
|
41 |
Adds a node as the last node in a list. */
|
|
42 |
||
43 |
void
|
|
44 |
flst_add_last( |
|
45 |
/*==========*/
|
|
46 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
47 |
flst_node_t* node, /* in: node to add */ |
|
48 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
49 |
/************************************************************************
|
|
50 |
Adds a node as the first node in a list. */
|
|
51 |
||
52 |
void
|
|
53 |
flst_add_first( |
|
54 |
/*===========*/
|
|
55 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
56 |
flst_node_t* node, /* in: node to add */ |
|
57 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
58 |
/************************************************************************
|
|
59 |
Inserts a node after another in a list. */
|
|
60 |
||
61 |
void
|
|
62 |
flst_insert_after( |
|
63 |
/*==============*/
|
|
64 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
65 |
flst_node_t* node1, /* in: node to insert after */ |
|
66 |
flst_node_t* node2, /* in: node to add */ |
|
67 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
68 |
/************************************************************************
|
|
69 |
Inserts a node before another in a list. */
|
|
70 |
||
71 |
void
|
|
72 |
flst_insert_before( |
|
73 |
/*===============*/
|
|
74 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
75 |
flst_node_t* node2, /* in: node to insert */ |
|
76 |
flst_node_t* node3, /* in: node to insert before */ |
|
77 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
78 |
/************************************************************************
|
|
79 |
Removes a node. */
|
|
80 |
||
81 |
void
|
|
82 |
flst_remove( |
|
83 |
/*========*/
|
|
84 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
85 |
flst_node_t* node2, /* in: node to remove */ |
|
86 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
87 |
/************************************************************************
|
|
88 |
Cuts off the tail of the list, including the node given. The number of
|
|
89 |
nodes which will be removed must be provided by the caller, as this function
|
|
90 |
does not measure the length of the tail. */
|
|
91 |
||
92 |
void
|
|
93 |
flst_cut_end( |
|
94 |
/*=========*/
|
|
95 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
96 |
flst_node_t* node2, /* in: first node to remove */ |
|
97 |
ulint n_nodes,/* in: number of nodes to remove, |
|
98 |
must be >= 1 */
|
|
99 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
100 |
/************************************************************************
|
|
101 |
Cuts off the tail of the list, not including the given node. The number of
|
|
102 |
nodes which will be removed must be provided by the caller, as this function
|
|
103 |
does not measure the length of the tail. */
|
|
104 |
||
105 |
void
|
|
106 |
flst_truncate_end( |
|
107 |
/*==============*/
|
|
108 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
109 |
flst_node_t* node2, /* in: first node not to remove */ |
|
110 |
ulint n_nodes,/* in: number of nodes to remove */ |
|
111 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
112 |
/************************************************************************
|
|
113 |
Gets list length. */
|
|
114 |
UNIV_INLINE
|
|
115 |
ulint
|
|
116 |
flst_get_len( |
|
117 |
/*=========*/
|
|
118 |
/* out: length */
|
|
119 |
flst_base_node_t* base, /* in: pointer to base node */ |
|
120 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
121 |
/************************************************************************
|
|
122 |
Gets list first node address. */
|
|
123 |
UNIV_INLINE
|
|
124 |
fil_addr_t
|
|
125 |
flst_get_first( |
|
126 |
/*===========*/
|
|
127 |
/* out: file address */
|
|
128 |
flst_base_node_t* base, /* in: pointer to base node */ |
|
129 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
130 |
/************************************************************************
|
|
131 |
Gets list last node address. */
|
|
132 |
UNIV_INLINE
|
|
133 |
fil_addr_t
|
|
134 |
flst_get_last( |
|
135 |
/*==========*/
|
|
136 |
/* out: file address */
|
|
137 |
flst_base_node_t* base, /* in: pointer to base node */ |
|
138 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
139 |
/************************************************************************
|
|
140 |
Gets list next node address. */
|
|
141 |
UNIV_INLINE
|
|
142 |
fil_addr_t
|
|
143 |
flst_get_next_addr( |
|
144 |
/*===============*/
|
|
145 |
/* out: file address */
|
|
146 |
flst_node_t* node, /* in: pointer to node */ |
|
147 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
148 |
/************************************************************************
|
|
149 |
Gets list prev node address. */
|
|
150 |
UNIV_INLINE
|
|
151 |
fil_addr_t
|
|
152 |
flst_get_prev_addr( |
|
153 |
/*===============*/
|
|
154 |
/* out: file address */
|
|
155 |
flst_node_t* node, /* in: pointer to node */ |
|
156 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
157 |
/************************************************************************
|
|
158 |
Writes a file address. */
|
|
159 |
UNIV_INLINE
|
|
160 |
void
|
|
161 |
flst_write_addr( |
|
162 |
/*============*/
|
|
163 |
fil_faddr_t* faddr, /* in: pointer to file faddress */ |
|
164 |
fil_addr_t addr, /* in: file address */ |
|
165 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
166 |
/************************************************************************
|
|
167 |
Reads a file address. */
|
|
168 |
UNIV_INLINE
|
|
169 |
fil_addr_t
|
|
170 |
flst_read_addr( |
|
171 |
/*===========*/
|
|
172 |
/* out: file address */
|
|
173 |
fil_faddr_t* faddr, /* in: pointer to file faddress */ |
|
174 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
175 |
/************************************************************************
|
|
176 |
Validates a file-based list. */
|
|
177 |
||
178 |
ibool
|
|
179 |
flst_validate( |
|
180 |
/*==========*/
|
|
181 |
/* out: TRUE if ok */
|
|
182 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
183 |
mtr_t* mtr1); /* in: mtr */ |
|
184 |
/************************************************************************
|
|
185 |
Prints info of a file-based list. */
|
|
186 |
||
187 |
void
|
|
188 |
flst_print( |
|
189 |
/*=======*/
|
|
190 |
flst_base_node_t* base, /* in: pointer to base node of list */ |
|
191 |
mtr_t* mtr); /* in: mtr */ |
|
192 |
||
193 |
||
194 |
#ifndef UNIV_NONINL
|
|
195 |
#include "fut0lst.ic" |
|
196 |
#endif
|
|
197 |
||
198 |
#endif
|