X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fpset_new.h;h=77feb7c5dc654a1c027bef338a8e79bcc6266dd8;hb=3db23eee84cbabb3f399f1ca820948114a9c837c;hp=530f9adcaeadf0563bd8364e3bfb75d1747ef5b8;hpb=3c53cd3d2cb9b7e7b7d31d75be755308caa4c3fa;p=libfirm diff --git a/ir/adt/pset_new.h b/ir/adt/pset_new.h index 530f9adca..77feb7c5d 100644 --- a/ir/adt/pset_new.h +++ b/ir/adt/pset_new.h @@ -1,15 +1,39 @@ +/* + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /** * @file * @date 17.03.2007 - * @brief A hashset that contains pointers + * @brief hashset containing pointers * @author Matthias Braun - * @version $Id: pset_new.h 169 2007-04-03 01:01:09Z uxsm $ * - * NOTE: This has been named pset_new_new for now until all code has been changed - * to use this instead of the old deprecated pset_new functions! + * @note This has been named pset_new_new for now until all code has been + * changed to use this instead of the old deprecated pset_new functions! + * This version performs better than pset in terms of speed and memory + * usage and allows multiple iterators over the set */ -#ifndef _FIRM_PSET_NEW_H_ -#define _FIRM_PSET_NEW_H_ +#ifndef FIRM_ADT_PSET_NEW_H +#define FIRM_ADT_PSET_NEW_H + +#include + +/** @cond PRIVATE */ #define HashSet pset_new_t #define HashSetIterator pset_new_iterator_t @@ -21,6 +45,14 @@ #undef HashSetIterator #undef ValueType +/** @endcond */ + +/** a pointer (hash)set */ +typedef struct pset_new_t pset_new_t; +/** iterator over a pointer set. + * @see #pset_new_t */ +typedef struct pset_new_iterator_t pset_new_iterator_t; + /** * Initializes a pset_new * @@ -31,8 +63,8 @@ void pset_new_init(pset_new_t *pset_new); /** * Initializes a pset_new * - * @param pset_new Pointer to allocated space for the pset_new - * @param expected_elements Number of elements expected in the pset_new (rougly) + * @param pset_new Pointer to allocated space for the pset_new + * @param expected_elements Number of elements expected in the pset_new (roughly) */ void pset_new_init_size(pset_new_t *pset_new, size_t expected_elements); @@ -49,9 +81,9 @@ void pset_new_destroy(pset_new_t *pset_new); * * @param pset_new Pointer to the pset_new * @param ptr Pointer to insert into the pset_new - * @returns 1 if the pointer was inserted, 0 if it was already there + * @returns true if the pointer was inserted, false if it was already there */ -int pset_new_insert(pset_new_t *pset_new, void *ptr); +bool pset_new_insert(pset_new_t *pset_new, void *ptr); /** * Removes an element from a pset_new. Does nothing if the pset_new doesn't contain the @@ -67,9 +99,8 @@ void pset_new_remove(pset_new_t *pset_new, const void *ptr); * * @param pset_new Pointer to the pset_new * @param ptr The pointer to test - * @returns 1 @p pset_new contains the @p ptr, 0 otherwise */ -int pset_new_contains(const pset_new_t *pset_new, const void *ptr); +bool pset_new_contains(const pset_new_t *pset_new, const void *ptr); /** * Returns the number of pointers contained in the pset_new @@ -110,9 +141,9 @@ void pset_new_remove_iterator(pset_new_t *pset_new, const pset_new_iterator_t *i /** * Convenience macro for iterating over a pset_new. */ -#define foreach_pset_new(pset_new, ptr, iter) \ +#define foreach_pset_new(pset_new, type, ptr, iter) \ for(pset_new_iterator_init(&iter, pset_new), \ - ptr = pset_new_iterator_next(&iter); \ - ptr != NULL; ptr = pset_new_iterator_next(&iter)) + ptr = (type) pset_new_iterator_next(&iter); \ + ptr != NULL; ptr = (type) pset_new_iterator_next(&iter)) -#endif /* _FIRM_PSET_NEW_H_ */ +#endif