Hash :
661fc57b
Author :
Date :
2018-12-01T01:16:25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_idxmap_h__
#define INCLUDE_idxmap_h__
#include "common.h"
#include "git2/index.h"
/** A map with `git_index_entry`s as key. */
typedef struct kh_idx_s git_idxmap;
/** A map with case-insensitive `git_index_entry`s as key */
typedef struct kh_idxicase_s git_idxmap_icase;
/**
* Allocate a new index entry map.
*
* @param out Pointer to the map that shall be allocated.
* @return 0 on success, an error code if allocation has failed.
*/
int git_idxmap_new(git_idxmap **out);
/**
* Allocate a new case-insensitive index entry map.
*
* @param out Pointer to the map that shall be allocated.
* @return 0 on success, an error code if allocation has failed.
*/
int git_idxmap_icase_new(git_idxmap_icase **out);
/**
* Free memory associated with the map.
*
* Note that this function will _not_ free values added to this
* map.
*
* @param map Pointer to the map that is to be free'd. May be
* `NULL`.
*/
void git_idxmap_free(git_idxmap *map);
/**
* Free memory associated with the map.
*
* Note that this function will _not_ free values added to this
* map.
*
* @param map Pointer to the map that is to be free'd. May be
* `NULL`.
*/
void git_idxmap_icase_free(git_idxmap_icase *map);
/**
* Clear all entries from the map.
*
* This function will remove all entries from the associated map.
* Memory associated with it will not be released, though.
*
* @param map Pointer to the map that shall be cleared. May be
* `NULL`.
*/
void git_idxmap_clear(git_idxmap *map);
/**
* Clear all entries from the map.
*
* This function will remove all entries from the associated map.
* Memory associated with it will not be released, though.
*
* @param map Pointer to the map that shall be cleared. May be
* `NULL`.
*/
void git_idxmap_icase_clear(git_idxmap_icase *map);
/**
* Return value associated with the given key.
*
* @param map map to search key in
* @param key key to search for; the index entry will be searched
* for by its case-sensitive path
* @return value associated with the given key or NULL if the key was not found
*/
void *git_idxmap_get(git_idxmap *map, const git_index_entry *key);
/**
* Return value associated with the given key.
*
* @param map map to search key in
* @param key key to search for; the index entry will be searched
* for by its case-insensitive path
* @return value associated with the given key or NULL if the key was not found
*/
void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key);
/**
* Set the entry for key to value.
*
* If the map has no corresponding entry for the given key, a new
* entry will be created with the given value. If an entry exists
* already, its value will be updated to match the given value.
*
* @param map map to create new entry in
* @param key key to set
* @param value value to associate the key with; may be NULL
* @return zero if the key was successfully set, a negative error
* code otherwise
*/
int git_idxmap_set(git_idxmap *map, const git_index_entry *key, void *value);
/**
* Set the entry for key to value.
*
* If the map has no corresponding entry for the given key, a new
* entry will be created with the given value. If an entry exists
* already, its value will be updated to match the given value.
*
* @param map map to create new entry in
* @param key key to set
* @param value value to associate the key with; may be NULL
* @return zero if the key was successfully set, a negative error
* code otherwise
*/
int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void *value);
void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval);
void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval);
size_t git_idxmap_lookup_index(git_idxmap *map, const git_index_entry *key);
size_t git_idxmap_icase_lookup_index(git_idxmap_icase *map, const git_index_entry *key);
void *git_idxmap_value_at(git_idxmap *map, size_t idx);
int git_idxmap_valid_index(git_idxmap *map, size_t idx);
int git_idxmap_icase_valid_index(git_idxmap_icase *map, size_t idx);
int git_idxmap_has_data(git_idxmap *map, size_t idx);
int git_idxmap_icase_has_data(git_idxmap_icase *map, size_t idx);
void git_idxmap_resize(git_idxmap *map, size_t size);
void git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
void git_idxmap_delete_at(git_idxmap *map, size_t idx);
void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
void git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
void git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
#endif