X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fhmap.h;h=095edf104674ba0af56b2a2da7d0bb4687807c0d;hb=91c50c1bf38fa2377a685343608b88915aa0168a;hp=c9e764dec563a92df08491839259e5f061884963;hpb=cb72db62c20ecab427229110820c5b053d0663c4;p=pspp diff --git a/src/libpspp/hmap.h b/src/libpspp/hmap.h index c9e764dec5..095edf1046 100644 --- a/src/libpspp/hmap.h +++ b/src/libpspp/hmap.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -115,6 +115,7 @@ } */ +#include #include #include @@ -157,6 +158,7 @@ struct hmap /* Creation and destruction. */ void hmap_init (struct hmap *); void hmap_swap (struct hmap *, struct hmap *); +void hmap_clear (struct hmap *); void hmap_destroy (struct hmap *); /* Storage management. */ @@ -182,6 +184,7 @@ static inline struct hmap_node *hmap_next (const struct hmap *, const struct hmap_node *); /* Counting. */ +static bool hmap_is_empty (const struct hmap *); static inline size_t hmap_count (const struct hmap *); static inline size_t hmap_capacity (const struct hmap *); @@ -442,6 +445,14 @@ hmap_next (const struct hmap *map, const struct hmap_node *node) : hmap_first_nonempty_bucket__ (map, (node->hash & map->mask) + 1)); } +/* Returns true if MAP currently contains no data items, false + otherwise. */ +static inline bool +hmap_is_empty (const struct hmap *map) +{ + return map->count == 0; +} + /* Returns the number of data items currently in MAP. */ static inline size_t hmap_count (const struct hmap *map)