polar-objc 5.44
An Objective-C runtime library
Loading...
Searching...
No Matches
polar-list-node.h
1/* Internal API: root linked-list node type for polar-objc.
2 Copyright (C) 2022-2025 Michael Malicoat <[email protected]>
3
4 This file is part of polar-objc.
5
6 polar-objc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
8
9 polar-objc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 details.
12
13 You should have received a copy of the GNU General Public License along with this program; see the file LICENSE. If
14 not, see <http://www.gnu.org/licenses/>.
15*/
16
17#ifndef POLAR_LIST_NODE_H
18#define POLAR_LIST_NODE_H
19// polar_list_node *****************************************************************************************************
20
21typedef struct polar_list_node polar_list_node;
23
25{
26 polar_runtime_object data_inherited;
27 polar_list_node *node_next;
28};
29
31{
32 polar_runtime_object_class data_inherited;
33};
34
35#define POLAR_TYPE_LIST_NODE ( polar_list_node_get_type() )
36
37#define POLAR_LIST_NODE(inst) ( POLAR_INTERNAL_TYPE_CHECK_INSTANCE_CAST((inst), POLAR_TYPE_LIST_NODE, polar_list_node) )
38#define POLAR_IS_LIST_NODE(inst) ( POLAR_INTERNAL_TYPE_CHECK_INSTANCE_TYPE((inst), POLAR_TYPE_LIST_NODE) )
39#define POLAR_LIST_NODE_CLASS(klass) ( POLAR_INTERNAL_TYPE_CHECK_CLASS_CAST((klass), POLAR_TYPE_LIST_NODE, polar_list_node_class) )
40#define POLAR_IS_LIST_NODE_CLASS(klass) ( POLAR_INTERNAL_TYPE_CHECK_CLASS_TYPE((klass), POLAR_TYPE_LIST_NODE) )
41#define POLAR_LIST_NODE_GET_CLASS(inst) ( POLAR_INTERNAL_TYPE_INSTANCE_GET_CLASS((inst), POLAR_TYPE_LIST_NODE, polar_list_node_class) )
42
43POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_CONSTANT polar_internal_type
44polar_list_node_get_type( void );
45
46POLAR_FUNCTION_INTERNAL intptr_t
47polar_list_node_list_free( polar_list_node **p_node_first );
48
49POLAR_FUNCTION_INTERNAL polar_list_node *
50polar_list_node_list_reverse( polar_list_node **p_node_first );
51
52POLAR_FUNCTION_INTERNAL polar_list_node *
53polar_list_node_list_concat( polar_list_node **p_list1, polar_list_node *list2 );
54
55static inline polar_list_node *
56polar_list_node_list_push_first( polar_list_node **p_list, polar_list_node *node_new )
57{
58 assert( p_list != NULL );
59 assert( POLAR_IS_LIST_NODE(node_new) );
60
61 node_new->node_next = *p_list;
62 *p_list = node_new;
63
64 return node_new;
65}
66
67static inline polar_list_node *
68polar_list_node_list_pop_first( polar_list_node **p_list )
69{
70 polar_list_node *result;
71
72 assert( p_list != NULL );
73
74 result = *p_list;
75 if( result != NULL )
76 {
77 assert( POLAR_IS_LIST_NODE(result) );
78
79 *p_list = result->node_next;
80 result->node_next = NULL;
81 }
82
83 return result;
84}
85
86#endif // POLAR_LIST_NODE_H
Definition polar-list-node.h:31
Definition polar-list-node.h:25
Definition polar-runtime-object.h:36
Definition polar-runtime-object.h:31