diff options
| author | Tyge Løvset <[email protected]> | 2021-04-12 11:00:31 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-04-12 11:00:31 +0200 |
| commit | 8dcc8600eb7b4cb11df377a8ae78a24281657873 (patch) | |
| tree | 192bbcd788c75eeef7cbe22dbe00ec46e99d6995 | |
| parent | 4db3f43304da1c0b12dcefd15f9f80a4e5a76c79 (diff) | |
| download | STC-modified-8dcc8600eb7b4cb11df377a8ae78a24281657873.tar.gz STC-modified-8dcc8600eb7b4cb11df377a8ae78a24281657873.zip | |
Fixed bug in csmap_X_erase_at() when erasing last element in map.
| -rw-r--r-- | docs/clist_api.md | 4 | ||||
| -rw-r--r-- | stc/csmap.h | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md index 4660ad9c..9d0945d6 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -1,10 +1,10 @@ -# STC [clist](../stc/clist.h): Singly Linked List +# STC [clist](../stc/clist.h): Forward List  The **clist** container supports fast insertion and removal of elements from anywhere in the container. Fast random access is not supported. -Unlike the c++ class *std::forward_list*, **clist** has an API similar to *std::list*, and also supports +Unlike the c++ class *std::forward_list*, **clist** has an API similar to ***std::list***, and also supports *push_back()* (**O**(1) time). It is still implemented as a singly-linked list. A **clist** object occupies only one pointer in memory, and like *std::forward_list* the length of the list is not stored. The method *clist_X_count()* returns size of list, computed in **O**(*n*) time. diff --git a/stc/csmap.h b/stc/csmap.h index 7171a128..2c0b817a 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -501,10 +501,11 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0}; \
STC_DEF CX##_iter_t \
CX##_erase_at(CX* self, CX##_iter_t it) { \
- RawKey raw = keyToRaw(KEY_REF_##C(it.ref)); CX##_next(&it); \
- RawKey nxt = keyToRaw(KEY_REF_##C(it.ref)); \
+ RawKey raw = keyToRaw(KEY_REF_##C(it.ref)), nxt; \
+ CX##_next(&it); \
+ if (it.ref) nxt = keyToRaw(KEY_REF_##C(it.ref)); \
CX##_erase(self, raw); \
- CX##_find_it(self, nxt, &it); \
+ if (it.ref) CX##_find_it(self, nxt, &it); \
return it; \
} \
\
|
