the_Foundation 1.0
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
stringset.h File Reference
#include "object.h"
#include "sortedarray.h"
#include "string.h"

Data Structures

struct  iStringSetClass
 
struct  iStringSet
 
struct  iStringSetReverseConstIterator
 

Macros

#define at_StringSet(d, pos)   at_SortedArray(&(d)->strings, pos)
 
#define isEmpty_StringSet(d)   isEmpty_SortedArray(&(d)->strings)
 

Typedefs

typedef int(* iStringSetCompareFunc) (const iString *, const iString *)
 

Functions

iStringSet * new_StringSet (void)
 
void init_StringSet (iStringSet *d)
 
void deinit_StringSet (iStringSet *d)
 
iStringSet * newCmp_StringSet (iStringSetCompareFunc cmp)
 
iStringSet * copy_StringSet (const iStringSet *)
 
iBool contains_StringSet (const iStringSet *, const iString *value)
 
iBool locate_StringSet (const iStringSet *, const iString *value, size_t *pos_out)
 
iRanges locateRange_StringSet (const iStringSet *, const iString *value, iStringSetCompareFunc relaxed)
 
void clear_StringSet (iStringSet *)
 
iBool insert_StringSet (iStringSet *, const iString *value)
 
iBool remove_StringSet (iStringSet *, const iString *value)
 
iBool insertIf_StringSet (iStringSet *, const iString *value, iStringSetCompareFunc pred)
 
iString * joinCStr_StringSet (const iStringSet *, const char *sep)
 

Variables

iStringSetClass Class_StringSet
 

Iterators

#define index_StringSetConstIterator(d)   index_ArrayConstIterator(&(d)->iter)
 
void init_StringSetConstIterator (iStringSetConstIterator *, const iStringSet *)
 
void next_StringSetConstIterator (iStringSetConstIterator *)
 
void init_StringSetReverseConstIterator (iStringSetReverseConstIterator *, const iStringSet *)
 
void next_StringSetReverseConstIterator (iStringSetReverseConstIterator *)
 

Detailed Description

Sorted array of strings.

Authors
Copyright (c) 2020 Jaakko Keränen jaakk.nosp@m.o.ke.nosp@m.ranen.nosp@m.@iki.nosp@m..fi
License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ insertIf_StringSet()

iBool insertIf_StringSet ( iStringSet * ,
const iString * value,
iStringSetCompareFunc pred )

Inserts a new element, or replaces an existing one if the provided predicate is true.

Parameters
valueValue to be inserted.
predPredicate callback that returns non-zero if the value should be inserted. Called to compare an existing value and the new value. Called as: pred(new, old)
Returns
True if value was inserted to the array.

◆ locateRange_StringSet()

iRanges locateRange_StringSet ( const iStringSet * ,
const iString * value,
iStringSetCompareFunc relaxed )

Locates a range of strings in the array.

Parameters
strString to be used for comparisons.
relaxedOptional comparison function that is more relaxed than the array's own element comparison function. This allows locating a range of elements that match partially. The relaxed comparison must be compatible with the array's comparison function. Set to NULL to use the array's comparison function.
Returns
Located range of elements. This is an empty range if nothing was found to match.