#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "Hash.h"
#include "IndexPath.h"
Go to the source code of this file.
◆ _Class
◆ _IndexPath()
| Class * _IndexPath |
( |
void |
| ) |
|
Definition at line 180 of file IndexPath.c.
180 {
183
186 .name = "IndexPath",
189 .interfaceOffset = offsetof(
IndexPath, interface),
190 .interfaceSize = sizeof(IndexPathInterface),
192 });
193 });
194
195 return clazz;
196}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
static void initialize(Class *clazz)
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
Index paths represent the path to an element or node within a tree or graph structure.
◆ copy()
- See also
- Object::copy(const Object *)
Definition at line 39 of file IndexPath.c.
39 {
40
43
45}
#define alloc(type)
Allocate and initialize and instance of type.
static IndexPath * initWithIndexes(IndexPath *self, size_t *indexes, size_t length)
Object is the root Class of The Objectively Class hierarchy.
◆ dealloc()
| static void dealloc |
( |
Object * |
self | ) |
|
|
static |
◆ description()
- See also
- Object::description(const Object *)
Definition at line 62 of file IndexPath.c.
62 {
63
66
67 for (size_t i = 0; i < this->length; i++) {
69 if (i < this->length - 1) {
71 }
72 }
73
76}
String * str(const char *fmt,...)
static void appendCharacters(String *self, const char *chars)
static void appendFormat(String *self, const char *fmt,...)
◆ hash()
| static int hash |
( |
const Object * |
self | ) |
|
|
static |
- See also
- Object::hash(const Object *)
Definition at line 81 of file IndexPath.c.
81 {
82
84
86
87 for (size_t i = 0; i < this->length; i++) {
89 }
90
92}
int HashForInteger(int hash, const long integer)
Accumulates the hash value of integer into hash.
#define HASH_SEED
The hash seed value.
static int hash(const Object *self)
◆ indexAtPosition()
| static size_t indexAtPosition |
( |
const IndexPath * |
self, |
|
|
size_t |
position |
|
) |
| |
|
static |
Definition at line 122 of file IndexPath.c.
122 {
123
124 assert(position < self->length);
125
126 return self->
indexes[position];
127}
size_t * indexes
The indexes.
◆ initialize()
| static void initialize |
( |
Class * |
clazz | ) |
|
|
static |
- See also
- Class::initialize(Class *)
Definition at line 163 of file IndexPath.c.
163 {
164
170
174}
static bool isEqual(const Object *self, const Object *other)
static IndexPath * initWithIndex(IndexPath *self, size_t index)
static size_t indexAtPosition(const IndexPath *self, size_t position)
static String * description(const Object *self)
static Object * copy(const Object *self)
ident interface
The interface of the Class.
IndexPath * initWithIndexes(IndexPath *self, size_t *indexes, size_t length)
Initializes this IndexPath with the specified indexes and length.
int hash(const Object *self)
void dealloc(Object *self)
Frees all resources held by this Object.
◆ initWithIndex()
◆ initWithIndexes()
Definition at line 141 of file IndexPath.c.
141 {
142
144 if (self) {
145
148
149 self->
indexes = calloc(
sizeof(
size_t), length);
151
152 memcpy(self->
indexes, indexes,
sizeof(
size_t) * length);
153 }
154
155 return self;
156}
static Array * init(Array *self)
size_t length
The length of indexes.
◆ isEqual()
| static bool isEqual |
( |
const Object * |
self, |
|
|
const Object * |
other |
|
) |
| |
|
static |
- See also
- Object::isEqual(const Object *, const Object *)
Definition at line 97 of file IndexPath.c.
97 {
98
100 return true;
101 }
102
104
107
108 if (this->length == that->
length) {
109 return memcmp(this->indexes, that->
indexes, this->length *
sizeof(
size_t)) == 0;
110 }
111 }
112
113 return false;
114}
static bool isKindOfClass(const Object *self, const Class *clazz)