Skip to content

Commit

Permalink
Clean up broken references
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanpranav committed Jan 30, 2024
1 parent 1ffa105 commit d913092
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 35 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ factor_iterator.o: lib/factor_iterator.c lib/factor_iterator.h
list.o: lib/list.c lib/list.h
$(CC) $(CFLAGS) -c $< -o $@

string.o: lib/string.c lib/string.h
math.o: lib/math.c lib/euler.h
$(CC) $(CFLAGS) -c $< -o $@

string_builder.o: lib/string_builder.c lib/string_builder.h
permutation_iterator.o: lib/permutation_iterator.c lib/permutation_iterator.h
$(CC) $(CFLAGS) -c $< -o $@

string_collection.o: lib/string_collection.c lib/string_collection.h
sieve.o: lib/sieve.c lib/sieve.h
$(CC) $(CFLAGS) -c $< -o $@

math.o: lib/math.c lib/euler.h
series.o: lib/series.c lib/series.h
$(CC) $(CFLAGS) -c $< -o $@

permutation_iterator.o: lib/permutation_iterator.c lib/permutation_iterator.h
string.o: lib/string.c lib/string.h
$(CC) $(CFLAGS) -c $< -o $@

sieve.o: lib/sieve.c lib/sieve.h
string_builder.o: lib/string_builder.c lib/string_builder.h
$(CC) $(CFLAGS) -c $< -o $@

series.o: lib/series.c lib/series.h
string_collection.o: lib/string_collection.c lib/string_collection.h
$(CC) $(CFLAGS) -c $< -o $@

totient.o: lib/totient.c lib/totient.h
Expand Down
3 changes: 2 additions & 1 deletion lib/boolean_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ typedef struct BooleanSet* BooleanSet;
Exception boolean_set(BooleanSet instance, size_t capacity);

/**
* Intializes a `BooleanSet` instance. Do not call `finalize_boolean_set`.
* Intializes a static. `BooleanSet` instance. Do not call
* `finalize_boolean_set`.
*
* @param instance the `BooleanSet` instance.
* @param values the backing array for the set. The caller is responsible for
Expand Down
9 changes: 9 additions & 0 deletions lib/comparer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
/** Defines a method that a type implements to compare two objects. */
typedef int (*Comparer)(const void* left, const void* right);

/**
* Compares this instance to a specified character and returns an indication of
* their relative values.
*
* @param left A character to compare to `left`.
* @param right A character to compare to `right`.
* @return A signed integer that indicates the relative values of `left` and
* `right`.
*/
int char_comparer(const void* left, const void* right);

/**
Expand Down
8 changes: 8 additions & 0 deletions lib/equality_comparer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
/** Defines methods to support the comparison of objects for equality. */
typedef bool (*EqualityComparer)(Object left, Object right);

/**
* Returns a value indicating whether `left` is equal to `right`.
*
* @param left a character to compare to `left`.
* @param right a character to compare to `right`.
* @param return `true` if `left` has the same value as `right`; otherwise,
* `false.`
*/
bool char_equality_comparer(Object left, Object right);

/**
Expand Down
2 changes: 0 additions & 2 deletions lib/factorial.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Licensed under the MIT License.

#include "array.h"

/**
* Generates values of the factorial function for all inputs in the interval
* [0, `max`).
Expand Down
12 changes: 6 additions & 6 deletions lib/hashes/pjw_hash.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Licensed under the MIT License.

#include "elf_hash.h"
#include "pjw_hash.h"

size_t elf_hash(Object item, size_t size)
size_t pjw_hash(Object item, size_t size)
{
return elf_hash32(item, size);
}

uint32_t elf_hash32(Object item, size_t size)
uint32_t pjw_hash32(Object item, size_t size)
{
uint32_t result = 0;
uint32_t high;
char* begin = item;
char* end = begin + size;
unsigned char* begin = item;
unsigned char* end = begin + size;

for (char* p = begin; p < end; p++)
for (unsigned char* p = begin; p < end; p++)
{
result = (result << 4) + *p++;

Expand Down
4 changes: 2 additions & 2 deletions lib/hashes/pjw_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t elf_hash(Object item, size_t size);
size_t pjw_hash(Object item, size_t size);

/**
* Computes the PJW hash function used for Unix ELF files and returns a value
Expand All @@ -20,4 +20,4 @@ size_t elf_hash(Object item, size_t size);
* @param size the size of the `item` argument.
* @return A 32-bit hash code for the given item.
*/
uint32_t elf_hash32(Object item, size_t size);
uint32_t pjw_hash32(Object item, size_t size);
2 changes: 1 addition & 1 deletion lib/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <stdlib.h>
#include <string.h>
#include "array.h"
#include "euler.h"
#include "list.h"
#include "array.h"
#include "object.h"
#include "swap.h"

Expand Down
8 changes: 4 additions & 4 deletions lib/permutation_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

void permutation_begin(
PermutationIterator iterator,
void* items,
Array items,
size_t itemSize,
size_t length,
Comparer itemComparer)
Expand Down Expand Up @@ -60,7 +60,7 @@ void permutation_next(PermutationIterator iterator)
}

static size_t permutation_count(
void* items,
Array items,
size_t itemSize,
size_t length,
Object item,
Expand All @@ -82,9 +82,9 @@ static size_t permutation_count(
}

bool permutation_test(
void* left,
Array left,
size_t leftLength,
void* right,
Array right,
size_t rightLength,
size_t itemSize,
EqualityComparer itemComparer)
Expand Down
7 changes: 4 additions & 3 deletions lib/permutation_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <stdbool.h>
#include <stddef.h>
#include "array.h"
#include "comparer.h"
#include "equality_comparer.h"

Expand All @@ -28,7 +29,7 @@ typedef struct PermutationIterator* PermutationIterator;
*/
void permutation_begin(
PermutationIterator iterator,
void* items,
Array items,
size_t itemSize,
size_t length,
Comparer itemComparer);
Expand All @@ -50,9 +51,9 @@ void permutation_next(PermutationIterator iterator);
* @return `true` if `left` and `right` are permutations; otherwise, `false`.
*/
bool permutation_test(
void* left,
Array left,
size_t leftLength,
void* right,
Array right,
size_t rightLength,
size_t itemSize,
EqualityComparer itemComparer);
2 changes: 1 addition & 1 deletion lib/series.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Licensed under the MIT License.

#include "string.h"
#include "_/../string.h"

/** Represents a series of decimal digits. */
struct Series
Expand Down
1 change: 0 additions & 1 deletion lib/sieve.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "boolean_set.h"
#include "list.h"
#include "array.h"
#include "object.h"
#include "primality_test.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdlib.h>
#include <string.h>
#include "string.h"
#include "_/../string.h"

String string(size_t length)
{
Expand Down
43 changes: 40 additions & 3 deletions lib/string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <stdbool.h>
#include <stddef.h>
#include "_/../string.h"
#include "exception.h"
#include "string.h"

/** Represents a mutable string of characters. */
struct StringBuilder
Expand All @@ -26,20 +26,57 @@ typedef struct StringBuilder* StringBuilder;
*/
Exception string_builder(StringBuilder instance, size_t capacity);

/**
* Initializes a static `StringBuilder` instance using the specified string. Do
* not call `finalize_string_builder`.
*
* @param instance the `StringBuilder` instance.
* @param value the backing string for the builder. The caller is responsible
* for this argument.
*/
void string_builder_from_string(StringBuilder instance, String value);

/**
* Appends a specified char to this instance.
* Ensures that the capacity of this instance of `StringBuilder` is at least the
* specified value.
*
* @param instance the `StringBuilder` instance.
* @param value the char value.
* @param value the required minimum capacity.
* @return `EXCEPTION_OUT_OF_MEMORY` if there is not enough memory to complete
* the operation; otherwise `0`.
*/
Exception string_builder_ensure_capacity(
StringBuilder instance,
size_t capacity);

/**
* Appends a specified char to this instance.
*
* @param instance the `StringBuilder` instance.
* @param value the char to append.
* @return An exception; otherwise, `0`.
*/
Exception string_builder_append_char(StringBuilder instance, char value);

/**
* Appends a copy of the specified string to this instance.
*
* @param instance the `StringBuilder` instance.
* @param value the string to append.
* @return An exception; otherwise `0`.
*/
Exception string_builder_append_string(StringBuilder instance, String value);

/**
* Appends the string returned by processing a composite format string, which
* contains zero or more format items, to this instance. Each format item is
* replaced by the string representation of a corresponding object argument.
*
* @param instance the `StringBuilder` instance.
* @param format a composite format string, followed by a variable number of
* template arguments.
* @return An exception; otherwise, `0`.
*/
Exception string_builder_append_format(
StringBuilder instance,
String format,
Expand Down
2 changes: 1 addition & 1 deletion lib/string_collection.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed under the MIT License.

#include "_/../string.h"
#include "list.h"
#include "string.h"
#include "stream.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion src/id0016.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <gmp.h>
#include "../lib/euler.h"
#include "../lib/exception.h"
#include "../lib/string.h"
#include "../lib/series.h"
#include "../lib/string.h"

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion src/id0020.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <gmp.h>
#include "../lib/euler.h"
#include "../lib/exception.h"
#include "../lib/string.h"
#include "../lib/series.h"
#include "../lib/string.h"

int main(void)
{
Expand Down

0 comments on commit d913092

Please sign in to comment.