polar-objc 5.44
An Objective-C runtime library
Loading...
Searching...
No Matches
polar-paged-array-iterator.c
1/* Internal API: paged array iterator 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// polar_paged_array_iterator ******************************************************************************************
18// Private =============================================================================================================
19
20// This variable is initialized in polar_paged_array_iterator_get_type()
21static polar_paged_array_iterator_class class_polar_paged_array_iterator;
22
23// This variable is initialized in _polar_paged_array_iterator_class_init()
24//static polar_runtime_object_class *superclass_polar_paged_array_iterator = NULL;
25
26// ---------------------------------------------------------------------------------------------------------------------
27
28POLAR_FUNCTION_INTERNAL BOOL
29_polar_paged_array_iterator_get_next( polar_paged_array_iterator *self, void **out_next_element )
30{
31 assert( out_next_element != NULL );
32 assert( POLAR_IS_PAGED_ARRAY(self->array_target) );
33
34 if( self->idx_current <= self->array_target->idx_logical_max )
35 {
36 *out_next_element = polar_paged_array_get_element(self->array_target, self->idx_current);
37 self->idx_current++;
38
39 return YES;
40 }
41
42 return NO;
43}
44
45POLAR_FUNCTION_INTERNAL void
46_polar_paged_array_iterator_class_init( polar_paged_array_iterator_class *self )
47{
48 // Acquire our superclass
49 //superclass_polar_paged_array_iterator = POLAR_RUNTIME_OBJECT_CLASS(self)->class_superclass;
50
51 // Establish our virtual methods
52 ( (polar_iterator_class *)self )->get_next = (void *)_polar_paged_array_iterator_get_next;
53}
54
55static struct polar_internal_type_info pti_polar_paged_array_iterator =
56{
57 .name_type = "polar_paged_array_iterator",
58 .size_type_instance = sizeof(polar_paged_array_iterator),
59 .size_type_class = sizeof(polar_paged_array_iterator_class),
60 .type_class_init = (polar_func_runtime_object_class_lifecycle)_polar_paged_array_iterator_class_init
61};
62
63// Public ==============================================================================================================
64
65POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_CONSTANT polar_internal_type
66polar_paged_array_iterator_get_type( void )
67{
68 static polar_internal_type pt_polar_paged_array_iterator = POLAR_INTERNAL_TYPE_INVALID;
69
70 if( pt_polar_paged_array_iterator != POLAR_INTERNAL_TYPE_INVALID )
71 return pt_polar_paged_array_iterator;
72
73 pt_polar_paged_array_iterator = polar_internal_type_init( POLAR_TYPE_ITERATOR, &class_polar_paged_array_iterator,
74 &pti_polar_paged_array_iterator );
75
76 return pt_polar_paged_array_iterator;
77}
78
Definition polar-internal-type.h:34
Definition polar-iterator.h:30
Definition polar-paged-array-iterator.h:32
Definition polar-paged-array-iterator.h:25