summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-08-14 07:54:28 +0200
committerTyge Løvset <[email protected]>2020-08-14 07:54:28 +0200
commita3b7d48d5e9ee28751bb43297e8abdbd31778394 (patch)
treed541e2d77c1d6d74df3b8edda8e047ef0b963818
parent1aa7b8ff0952800ee26832f17dadf8a1a24d3848 (diff)
downloadSTC-modified-a3b7d48d5e9ee28751bb43297e8abdbd31778394.tar.gz
STC-modified-a3b7d48d5e9ee28751bb43297e8abdbd31778394.zip
Some cleanups.
-rw-r--r--examples/geek4.c4
-rw-r--r--examples/geek5.c4
-rw-r--r--examples/geek6.c2
-rw-r--r--examples/geek7.c2
-rw-r--r--stc/cbitset.h1
-rw-r--r--stc/cdefs.h6
6 files changed, 11 insertions, 8 deletions
diff --git a/examples/geek4.c b/examples/geek4.c
index 3672563d..b0a57844 100644
--- a/examples/geek4.c
+++ b/examples/geek4.c
@@ -152,7 +152,9 @@ int main()
// C++ implementation of the approach
-#include <bits/stdc++.h>
+#include <unordered_map>
+#include <vector>
+#include <iostream>
using namespace std;
// Function to return the count of common words
diff --git a/examples/geek5.c b/examples/geek5.c
index cbfc40e6..67f5d097 100644
--- a/examples/geek5.c
+++ b/examples/geek5.c
@@ -37,7 +37,7 @@ int NumOccurrences(const char* arr[], int n, const char* str, int L, int R)
// If current string doesn't
// have an entry in the map
// then create the entry
- if (it == c_nullptr) {
+ if (it == NULL) {
cvec_i A = cvec_init;
cvec_i_push_back(&A, i + 1);
cmap_sv_put(&M, temp, A);
@@ -51,7 +51,7 @@ int NumOccurrences(const char* arr[], int n, const char* str, int L, int R)
// If the given string is not
// present in the array
- if (it == c_nullptr)
+ if (it == NULL)
return 0;
// If the given string is present
diff --git a/examples/geek6.c b/examples/geek6.c
index b3991e99..db0b3bcf 100644
--- a/examples/geek6.c
+++ b/examples/geek6.c
@@ -52,7 +52,7 @@ int missingNumber(int a[], int n)
// Return the first value starting
// from 1 which does not exists in map
while (1) {
- if (cset_i_find(&mp, index) == c_nullptr) {
+ if (cset_i_find(&mp, index) == NULL) {
return index;
}
diff --git a/examples/geek7.c b/examples/geek7.c
index 0976bf80..9a60c0a9 100644
--- a/examples/geek7.c
+++ b/examples/geek7.c
@@ -49,7 +49,7 @@ void findElementsAfterDel(int arr[], int m, int del[],
// Search if the element is present
cmap_ii_entry_t *e = cmap_ii_find(&mp, arr[i]);
- if (e != c_nullptr) {
+ if (e != NULL) {
// Decrement its frequency
e->value--;
diff --git a/stc/cbitset.h b/stc/cbitset.h
index 8af4bfcb..8e443d55 100644
--- a/stc/cbitset.h
+++ b/stc/cbitset.h
@@ -188,6 +188,7 @@ STC_API size_t cbitset_count(cbitset_t s) {
}
#define _cbitset_SETOP(OPR) \
+ assert(s.size == other.size); \
if (s.size == 0) return false; /* ? */ \
size_t n = ((s.size + 63) >> 6) - 1; \
for (size_t i=0; i<n; ++i) \
diff --git a/stc/cdefs.h b/stc/cdefs.h
index 6136a7e1..f9867bce 100644
--- a/stc/cdefs.h
+++ b/stc/cdefs.h
@@ -60,11 +60,11 @@
#define c_new_n(T, n) ((T *) malloc(sizeof(T) * (n)))
#define c_max_alloca (512)
-#define c_swap(T, x, y) { T __t = x; x = y; y = __t; }
+#define c_swap(T, x, y) do { T __t = x; x = y; y = __t; } while (0)
#ifdef __cplusplus
-#define c_nullptr nullptr
+#define c_NULL nullptr
#else
-#define c_nullptr NULL
+#define c_NULL NULL
#endif
#define c_default_from_raw(x) (x)