#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "Hash.h"
#include "IndexPath.h"
#include "MutableString.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.
Class * _Object(void)
The Object archetype.
◆ 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.
IndexPath * initWithIndexes(IndexPath *self, size_t *indexes, size_t length)
Initializes this IndexPath with the specified indexes and length.
Object is the root Class of The Objectively Class hierarchy.
◆ dealloc()
static void dealloc |
( |
Object * |
self | ) |
|
|
static |
- See also
- Object::dealloc(Object *)
Definition at line 50 of file IndexPath.c.
50 {
51
53
54 free(this->indexes);
55
57}
#define super(type, obj, method,...)
void dealloc(Object *self)
Frees all resources held by this Object.
◆ 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}
void appendFormat(MutableString *self, const char *fmt,...)
Appends the specified formatted string.
void appendCharacters(MutableString *self, const char *chars)
Appends the specified UTF-8 encoded C string.
OBJECTIVELY_EXPORT MutableString * mstr(const char *fmt,...)
A convenience function for instantiating MutableStrings.
◆ 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.
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}
ident interface
The interface of the Class.
IndexPath * initWithIndex(IndexPath *self, size_t index)
Initializes this IndexPath with the specified index.
size_t indexAtPosition(const IndexPath *self, size_t position)
Object * copy(const Object *self)
Creates a shallow copy of this Object.
String * description(const Object *self)
_Bool isEqual(const Object *self, const Object *other)
Tests equality of the other 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}
Condition * init(Condition *self)
Initializes this Condition.
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}
Class * _IndexPath(void)
The IndexPath archetype.
_Bool isKindOfClass(const Object *self, const Class *clazz)
Tests for Class hierarchy membership.