Skip to content

Commit cf849a5

Browse files
committed
style: format code using clang-format
1 parent c9aa923 commit cf849a5

File tree

640 files changed

+1739
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

640 files changed

+1739
-1418
lines changed

.clang-format

+143-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,142 @@
1+
---
2+
Language: Java
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveMacros: false
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Right
9+
AlignOperands: false
10+
AlignTrailingComments: false
11+
AllowAllArgumentsOnNextLine: true
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: true
14+
AllowShortBlocksOnASingleLine: Never
15+
AllowShortCaseLabelsOnASingleLine: false
16+
AllowShortFunctionsOnASingleLine: false
17+
AllowShortLambdasOnASingleLine: All
18+
AllowShortIfStatementsOnASingleLine: true
19+
AllowShortLoopsOnASingleLine: true
20+
AlwaysBreakAfterDefinitionReturnType: None
21+
AlwaysBreakAfterReturnType: TopLevelDefinitions
22+
AlwaysBreakBeforeMultilineStrings: false
23+
AlwaysBreakTemplateDeclarations: MultiLine
24+
BinPackArguments: true
25+
BinPackParameters: true
26+
BraceWrapping:
27+
AfterCaseLabel: false
28+
AfterClass: false
29+
AfterControlStatement: false
30+
AfterEnum: false
31+
AfterFunction: false
32+
AfterNamespace: false
33+
AfterObjCDeclaration: false
34+
AfterStruct: false
35+
AfterUnion: false
36+
AfterExternBlock: false
37+
BeforeCatch: false
38+
BeforeElse: false
39+
IndentBraces: false
40+
SplitEmptyFunction: true
41+
SplitEmptyRecord: true
42+
SplitEmptyNamespace: true
43+
BreakBeforeBinaryOperators: All
44+
BreakBeforeBraces: Custom
45+
BreakBeforeInheritanceComma: false
46+
BreakInheritanceList: BeforeColon
47+
BreakBeforeTernaryOperators: true
48+
BreakConstructorInitializersBeforeComma: false
49+
BreakConstructorInitializers: BeforeComma
50+
BreakAfterJavaFieldAnnotations: false
51+
BreakStringLiterals: true
52+
ColumnLimit: 100
53+
CommentPragmas: '^ IWYU pragma:'
54+
CompactNamespaces: false
55+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
56+
ConstructorInitializerIndentWidth: 4
57+
ContinuationIndentWidth: 4
58+
Cpp11BracedListStyle: true
59+
DeriveLineEnding: true
60+
DerivePointerAlignment: false
61+
DisableFormat: false
62+
ExperimentalAutoDetectBinPacking: false
63+
FixNamespaceComments: false
64+
ForEachMacros:
65+
- foreach
66+
- Q_FOREACH
67+
- BOOST_FOREACH
68+
IncludeBlocks: Preserve
69+
IncludeCategories:
70+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
71+
Priority: 2
72+
SortPriority: 0
73+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
74+
Priority: 3
75+
SortPriority: 0
76+
- Regex: '.*'
77+
Priority: 1
78+
SortPriority: 0
79+
IncludeIsMainRegex: '(Test)?$'
80+
IncludeIsMainSourceRegex: ''
81+
IndentCaseLabels: false
82+
IndentGotoLabels: true
83+
IndentPPDirectives: None
84+
IndentWidth: 4
85+
IndentWrappedFunctionNames: false
86+
JavaScriptQuotes: Leave
87+
JavaScriptWrapImports: true
88+
KeepEmptyLinesAtTheStartOfBlocks: true
89+
MacroBlockBegin: ''
90+
MacroBlockEnd: ''
91+
MaxEmptyLinesToKeep: 1
92+
NamespaceIndentation: Inner
93+
ObjCBinPackProtocolList: Auto
94+
ObjCBlockIndentWidth: 4
95+
ObjCSpaceAfterProperty: true
96+
ObjCSpaceBeforeProtocolList: true
97+
PenaltyBreakAssignment: 2
98+
PenaltyBreakBeforeFirstCallParameter: 19
99+
PenaltyBreakComment: 300
100+
PenaltyBreakFirstLessLess: 120
101+
PenaltyBreakString: 1000
102+
PenaltyBreakTemplateDeclaration: 10
103+
PenaltyExcessCharacter: 1000000
104+
PenaltyReturnTypeOnItsOwnLine: 60
105+
PointerAlignment: Left
106+
ReflowComments: true
107+
SortIncludes: true
108+
SortUsingDeclarations: true
109+
SpaceAfterCStyleCast: true
110+
SpaceAfterLogicalNot: false
111+
SpaceAfterTemplateKeyword: true
112+
SpaceBeforeAssignmentOperators: true
113+
SpaceBeforeCpp11BracedList: false
114+
SpaceBeforeCtorInitializerColon: true
115+
SpaceBeforeInheritanceColon: true
116+
SpaceBeforeParens: ControlStatements
117+
SpaceBeforeRangeBasedForLoopColon: true
118+
SpaceInEmptyBlock: false
119+
SpaceInEmptyParentheses: false
120+
SpacesBeforeTrailingComments: 1
121+
SpacesInAngles: false
122+
SpacesInConditionalStatement: false
123+
SpacesInContainerLiterals: false
124+
SpacesInCStyleCastParentheses: false
125+
SpacesInParentheses: false
126+
SpacesInSquareBrackets: false
127+
SpaceBeforeSquareBrackets: false
128+
Standard: Latest
129+
StatementMacros:
130+
- Q_UNUSED
131+
- QT_REQUIRE_VERSION
132+
TabWidth: 8
133+
UseCRLF: false
134+
UseTab: Never
135+
...
136+
137+
138+
139+
1140
---
2141
Language: Cpp
3142
# BasedOnStyle: WebKit
@@ -107,21 +246,21 @@ PointerAlignment: Left
107246
ReflowComments: true
108247
SortIncludes: true
109248
SortUsingDeclarations: true
110-
SpaceAfterCStyleCast: false
249+
SpaceAfterCStyleCast: true
111250
SpaceAfterLogicalNot: false
112251
SpaceAfterTemplateKeyword: true
113252
SpaceBeforeAssignmentOperators: true
114-
SpaceBeforeCpp11BracedList: true
253+
SpaceBeforeCpp11BracedList: false
115254
SpaceBeforeCtorInitializerColon: true
116255
SpaceBeforeInheritanceColon: true
117256
SpaceBeforeParens: ControlStatements
118257
SpaceBeforeRangeBasedForLoopColon: true
119-
SpaceInEmptyBlock: true
258+
SpaceInEmptyBlock: false
120259
SpaceInEmptyParentheses: false
121260
SpacesBeforeTrailingComments: 1
122261
SpacesInAngles: false
123262
SpacesInConditionalStatement: false
124-
SpacesInContainerLiterals: true
263+
SpacesInContainerLiterals: false
125264
SpacesInCStyleCastParentheses: false
126265
SpacesInParentheses: false
127266
SpacesInSquareBrackets: false

basic/sorting/CountingSort/CountingSort.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
public static void sort(int[] nums, int min, int max) {
1+
public static void
2+
sort(int[] nums, int min, int max) {
23
int n = nums.length;
34
int k = max - min + 1;
45
int[] c = new int[k];

basic/sorting/HeapSort/Main.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Main {
44
private static int[] h = new int[100010];
55
private static int size;
6-
6+
77
public static void main(String[] args) {
88
Scanner sc = new Scanner(System.in);
99
int n = sc.nextInt(), m = sc.nextInt();
@@ -20,7 +20,7 @@ public static void main(String[] args) {
2020
down(1);
2121
}
2222
}
23-
23+
2424
public static void down(int u) {
2525
int t = u;
2626
if (u * 2 <= size && h[u * 2] < h[t]) {
@@ -34,14 +34,14 @@ public static void down(int u) {
3434
down(t);
3535
}
3636
}
37-
37+
3838
public static void up(int u) {
3939
while (u / 2 > 0 && h[u / 2] > h[u]) {
4040
swap(u / 2, u);
4141
u /= 2;
4242
}
4343
}
44-
44+
4545
public static void swap(int i, int j) {
4646
int t = h[i];
4747
h[i] = h[j];

basic/sorting/InsertionSort/InsertionSort.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class InsertionSort {
55
private static void insertionSort(int[] nums) {
66
for (int i = 1, j, n = nums.length; i < n; ++i) {
77
int num = nums[i];
8-
for (j = i - 1; j >=0 && nums[j] > num; --j) {
8+
for (j = i - 1; j >= 0 && nums[j] > num; --j) {
99
nums[j + 1] = nums[j];
1010
}
1111
nums[j + 1] = num;

basic/sorting/MergeSort/Main.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Main {
44
private static int[] tmp = new int[100010];
5-
5+
66
public static void main(String[] args) {
77
Scanner sc = new Scanner(System.in);
88
int n = sc.nextInt();
@@ -15,7 +15,7 @@ public static void main(String[] args) {
1515
System.out.print(x + " ");
1616
}
1717
}
18-
18+
1919
public static void mergeSort(int[] nums, int left, int right) {
2020
if (left >= right) {
2121
return;
@@ -30,7 +30,6 @@ public static void mergeSort(int[] nums, int left, int right) {
3030
} else {
3131
tmp[k++] = nums[j++];
3232
}
33-
3433
}
3534
while (i <= mid) {
3635
tmp[k++] = nums[i++];

basic/sorting/QuickSort/Main.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ public static void main(String[] args) {
1313
System.out.print(nums[i] + " ");
1414
}
1515
}
16-
16+
1717
public static void quickSort(int[] nums, int left, int right) {
1818
if (left >= right) {
1919
return;
2020
}
2121
int i = left - 1, j = right + 1;
2222
int x = nums[(left + right) >> 1];
2323
while (i < j) {
24-
while (nums[++i] < x);
25-
while (nums[--j] > x);
24+
while (nums[++i] < x)
25+
;
26+
while (nums[--j] > x)
27+
;
2628
if (i < j) {
2729
int t = nums[i];
2830
nums[i] = nums[j];

basic/sorting/ShellSort/ShellSort.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ private static int[] shellSort(int[] arr) {
2020
}
2121

2222
public static void main(String[] args) {
23-
System.out.println(Arrays.toString(shellSort(new int[]{1, 2, 7, 9, 5, 8})));
23+
System.out.println(Arrays.toString(shellSort(new int[] {1, 2, 7, 9, 5, 8})));
2424
}
2525
}

lcci/03.02.Min Stack/Solution.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ public MinStack() {
88
mins = new ArrayDeque<>();
99
mins.push(Integer.MAX_VALUE);
1010
}
11-
11+
1212
public void push(int val) {
1313
s.push(val);
1414
mins.push(Math.min(mins.peek(), val));
1515
}
16-
16+
1717
public void pop() {
1818
s.pop();
1919
mins.pop();
2020
}
21-
21+
2222
public int top() {
2323
return s.peek();
2424
}
25-
25+
2626
public int getMin() {
2727
return mins.peek();
2828
}

lcci/03.04.Implement Queue using Stacks/Solution.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ public MyQueue() {
77
s1 = new Stack<>();
88
s2 = new Stack<>();
99
}
10-
10+
1111
/** Push element x to the back of queue. */
1212
public void push(int x) {
1313
s1.push(x);
1414
}
15-
15+
1616
/** Removes the element from in front of queue and returns that element. */
1717
public int pop() {
1818
if (s2.empty()) {
@@ -22,7 +22,7 @@ public int pop() {
2222
}
2323
return s2.pop();
2424
}
25-
25+
2626
/** Get the front element. */
2727
public int peek() {
2828
if (s2.empty()) {
@@ -32,7 +32,7 @@ public int peek() {
3232
}
3333
return s2.peek();
3434
}
35-
35+
3636
/** Returns whether the queue is empty. */
3737
public boolean empty() {
3838
return s1.empty() && s2.empty();

lcci/03.05.Sort of Stacks/Solution.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class SortedStack {
33
public SortedStack() {
44
s = new Stack<>();
55
}
6-
6+
77
public void push(int val) {
88
Stack<Integer> t = new Stack<>();
99
while (!isEmpty() && s.peek() < val) {
@@ -14,17 +14,17 @@ public void push(int val) {
1414
s.push(t.pop());
1515
}
1616
}
17-
17+
1818
public void pop() {
1919
if (!isEmpty()) {
2020
s.pop();
2121
}
2222
}
23-
23+
2424
public int peek() {
2525
return isEmpty() ? -1 : s.peek();
2626
}
27-
27+
2828
public boolean isEmpty() {
2929
return s.isEmpty();
3030
}

0 commit comments

Comments
 (0)