Browse Source

Expose term set size.

scossu 2 days ago
parent
commit
119cc4ce15
2 changed files with 15 additions and 0 deletions
  1. 10 0
      include/lsup/term.h
  2. 5 0
      src/term.c

+ 10 - 0
include/lsup/term.h

@@ -549,6 +549,16 @@ LSUP_rc
 LSUP_term_set_next (LSUP_TermSet *ts, size_t *i, LSUP_Term **term);
 
 
+/** @brief Size of a term set.
+ *
+ * @param[in] ts Term set handle.
+ *
+ * @return Number of unique terms in the term set.
+ */
+size_t
+LSUP_term_set_size (LSUP_TermSet *ts);
+
+
 /** @brief New link map.
  *
  * @param[in] linked_term Term to be linked to map. The term is copied and may

+ 5 - 0
src/term.c

@@ -607,6 +607,11 @@ LSUP_term_set_free (LSUP_TermSet *ts)
 }
 
 
+size_t
+LSUP_term_set_size (LSUP_TermSet *ts)
+{ return hashmap_count (ts); }
+
+
 LSUP_LinkMap *
 LSUP_link_map_new (const LSUP_Term *linked_term, LSUP_LinkType type)
 {