Bug fixes to hashmultiset

This commit is contained in:
Leonardo Vencovsky committed 2020-05-23 07:46:23 -03:00
1 parent 7340866da1
commit 8112ea6f42
2 files changed
+17 -2

No files matched your search

+10 -1
View File
@@ -1431,6 +1431,7 @@ static const char *cmc_string_fmt_hashmultiset = "struct %s<%s> "
size_t curr_mul = 1; \
\
struct SNAME##_entry *target = &(_set_->buffer[pos]); \
struct SNAME##_entry *to_return = NULL; \
\
if (target->state == CMC_ES_EMPTY || target->state == CMC_ES_DELETED) \
{ \
@@ -1438,6 +1439,8 @@ static const char *cmc_string_fmt_hashmultiset = "struct %s<%s> "
target->multiplicity = curr_mul; \
target->dist = pos - original_pos; \
target->state = CMC_ES_FILLED; \
\
to_return = target; \
} \
else \
{ \
@@ -1454,6 +1457,9 @@ static const char *cmc_string_fmt_hashmultiset = "struct %s<%s> "
target->dist = pos - original_pos; \
target->state = CMC_ES_FILLED; \
\
if (!to_return) \
to_return = target; \
\
break; \
} \
else if (target->dist < pos - original_pos) \
@@ -1470,13 +1476,16 @@ static const char *cmc_string_fmt_hashmultiset = "struct %s<%s> "
value = tmp; \
original_pos = pos - tmp_dist; \
curr_mul = tmp_mul; \
\
if (!to_return) \
to_return = target; \
} \
} \
} \
\
_set_->count++; \
\
return target; \
return to_return; \
} \
\
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_set_, \
+7 -1
View File
@@ -994,12 +994,14 @@ hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value,
size_t pos = original_pos;
size_t curr_mul = 1;
struct hashmultiset_entry *target = &(_set_->buffer[pos]);
struct hashmultiset_entry *to_return = ((void *)0);
if (target->state == CMC_ES_EMPTY || target->state == CMC_ES_DELETED)
{
target->value = value;
target->multiplicity = curr_mul;
target->dist = pos - original_pos;
target->state = CMC_ES_FILLED;
to_return = target;
}
else
{
@@ -1014,6 +1016,8 @@ hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value,
target->multiplicity = curr_mul;
target->dist = pos - original_pos;
target->state = CMC_ES_FILLED;
if (!to_return)
to_return = target;
break;
}
else if (target->dist < pos - original_pos)
@@ -1027,11 +1031,13 @@ hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value,
value = tmp;
original_pos = pos - tmp_dist;
curr_mul = tmp_mul;
if (!to_return)
to_return = target;
}
}
}
_set_->count++;
return target;
return to_return;
}
static struct hashmultiset_entry *hms_impl_get_entry(struct hashmultiset *_set_,
size_t value)