Skip to content

Commit 0356a9c

Browse files
committed
fix: Various LGTM fixes
1 parent 7393d88 commit 0356a9c

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

data_structures/binary_search_tree.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ struct node {
1414
node *right;
1515
};
1616

17-
struct queue {
17+
struct Queue {
1818
node *t[100];
1919
int front;
2020
int rear;
2121
};
2222

23-
queue q;
23+
Queue queue;
2424

25-
void enqueue(node *n) { q.t[q.rear++] = n; }
25+
void enqueue(node *n) { queue.t[queue.rear++] = n; }
2626

27-
node *dequeue() { return (q.t[q.front++]); }
27+
node *dequeue() { return (queue.t[queue.front++]); }
2828

2929
void Insert(node *n, int x) {
3030
if (x < n->val) {
@@ -123,8 +123,8 @@ void Post(node *n) {
123123
}
124124

125125
int main() {
126-
q.front = 0;
127-
q.rear = 0;
126+
queue.front = 0;
127+
queue.rear = 0;
128128
int value;
129129
int ch;
130130
node *root = new node;

math/realtime_stats.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class stats_computer1 {
3535
n++;
3636
T tmp = x - K;
3737
Ex += tmp;
38-
Ex2 += tmp * tmp;
38+
Ex2 += static_cast<double>(tmp) * tmp;
3939
}
4040

4141
/** return sample mean computed till last sample */

sorting/bead_sort.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void beadSort(int *a, int len) {
1414

1515
// allocating memory
1616
unsigned char *beads = new unsigned char[max * len];
17-
memset(beads, 0, max * len);
17+
memset(beads, 0, static_cast<size_t>(max) * len);
1818

1919
// mark the beads
2020
for (int i = 0; i < len; i++)

sorting/comb_sort.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int FindNextGap(int x) {
1414
return std::max(1, x);
1515
}
1616

17-
void CombSort(int a[], int l, int r) {
17+
void CombSort(int b[], int l, int r) {
1818
// Init gap
1919
int gap = n;
2020

@@ -30,8 +30,8 @@ void CombSort(int a[], int l, int r) {
3030

3131
// Compare all elements with current gap
3232
for (int i = l; i <= r - gap; ++i) {
33-
if (a[i] > a[i + gap]) {
34-
std::swap(a[i], a[i + gap]);
33+
if (b[i] > b[i + gap]) {
34+
std::swap(b[i], b[i + gap]);
3535
swapped = true;
3636
}
3737
}

0 commit comments

Comments
 (0)