1/*****************************************************************************
2
3Copyright (c) 2006, 2013, Oracle and/or its affiliates. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/*******************************************************************//**
20@file include/ut0list.ic
21A double-linked list
22
23Created 4/26/2006 Osku Salerma
24************************************************************************/
25
26/****************************************************************//**
27Get the first node in the list.
28@return first node, or NULL */
29UNIV_INLINE
30ib_list_node_t*
31ib_list_get_first(
32/*==============*/
33 ib_list_t* list) /*!< in: list */
34{
35 return(list->first);
36}
37
38/****************************************************************//**
39Get the last node in the list.
40@return last node, or NULL */
41UNIV_INLINE
42ib_list_node_t*
43ib_list_get_last(
44/*=============*/
45 ib_list_t* list) /*!< in: list */
46{
47 return(list->last);
48}
49
50/********************************************************************
51Check if list is empty. */
52UNIV_INLINE
53ibool
54ib_list_is_empty(
55/*=============*/
56 /* out: TRUE if empty else FALSE */
57 const ib_list_t* list) /* in: list */
58{
59 return(!(list->first || list->last));
60}
61
62/********************************************************************
63Get number of items on list.
64@return number of items on list */
65UNIV_INLINE
66ulint
67ib_list_len(
68/*========*/
69 const ib_list_t* list) /*<! in: list */
70{
71 ulint len = 0;
72 ib_list_node_t* node = list->first;
73
74 while(node) {
75 len++;
76 node = node->next;
77 }
78
79 return (len);
80}
81