Skip to content

Commit 6b6d3b5

Browse files
author
bbenligiray
committed
autoformatted
1 parent 26601f9 commit 6b6d3b5

File tree

16 files changed

+543
-629
lines changed

16 files changed

+543
-629
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
3+
*.zip binary

source/Button.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
#include "PosChart.h"
77
#include "enums.h"
88

9-
int getPosOfChar (const char *array, char c);
10-
void getLocOfChar (char c, int &loop, int &row);
9+
int getPosOfChar(const char *array, char c);
10+
void getLocOfChar(char c, int &loop, int &row);
1111

1212
//Holds every aspect of a button
13-
class Button
13+
class Button
1414
{
1515
DiskPart buttonShape;
1616
ValidChar writing;
1717

1818
public:
19-
Button ();
20-
Button (ValidChar inpWriting);
19+
Button();
20+
Button(ValidChar inpWriting);
2121
DiskPart& getButtonShape();
2222
ValidChar& getWriting();
2323
};
2424

25-
Button::Button ()
25+
Button::Button()
2626
{
2727
}
2828

29-
Button::Button (ValidChar inpWriting)
29+
Button::Button(ValidChar inpWriting)
3030
{
31-
writing=inpWriting;
31+
writing = inpWriting;
3232

3333
int loop, row;
34-
getLocOfChar (writing.getChar(), loop, row);
34+
getLocOfChar(writing.getChar(), loop, row);
3535

36-
buttonShape = DiskPart(loop,row);
36+
buttonShape = DiskPart(loop, row);
3737
}
3838

3939
DiskPart& Button::getButtonShape()
@@ -46,20 +46,20 @@ ValidChar& Button::getWriting()
4646
return writing;
4747
}
4848

49-
int getPosOfChar (const char *array, char c)
49+
int getPosOfChar(const char *array, char c)
5050
{
5151
size_t size = 26; //not cool
5252
const char* end = array + size;
53-
const char* match = std::find (array, end, c);
54-
return (end == match) ? -1 : (match-array);
53+
const char* match = std::find(array, end, c);
54+
return (end == match) ? -1 : (match - array);
5555
}
5656

57-
void getLocOfChar (char c, int &loop, int &row)
57+
void getLocOfChar(char c, int &loop, int &row)
5858
{
59-
int noOfChar = getPosOfChar (firstScreenChars, c);
59+
int noOfChar = getPosOfChar(firstScreenChars, c);
6060

6161
if (noOfChar == -1)
62-
noOfChar = getPosOfChar (secondScreenChars, c);
62+
noOfChar = getPosOfChar(secondScreenChars, c);
6363

6464
//middle loop
6565
if (noOfChar < 2)

source/ButtonSet.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,51 @@ class ButtonSet
1616
vector<Button> buttons;
1717
PosChart positions;
1818
void initPositions();
19-
void mergeButtons ();
19+
void mergeButtons();
2020

2121
public:
22-
ButtonSet ();
23-
ButtonSet (vector<ValidChar> writings);
22+
ButtonSet();
23+
ButtonSet(vector<ValidChar> writings);
2424
vector<Button>& getButtons();
25-
bool getButtonWithField (int inpLoop, int inpRow, Button& but);
25+
bool getButtonWithField(int inpLoop, int inpRow, Button& but);
2626
};
27-
ButtonSet::ButtonSet ()
27+
ButtonSet::ButtonSet()
2828
{}
29-
ButtonSet::ButtonSet (vector<ValidChar> writings)
29+
ButtonSet::ButtonSet(vector<ValidChar> writings)
3030
{
31-
for (vector<ValidChar>::size_type i = 0; i != writings.size () ; i++)
32-
buttons.push_back (Button (writings[i]));
33-
initPositions ();
34-
mergeButtons ();
31+
for (vector<ValidChar>::size_type i = 0; i != writings.size(); i++)
32+
buttons.push_back(Button(writings[i]));
33+
initPositions();
34+
mergeButtons();
3535
}
3636

3737
//fills positions with the oriinal (non-merged) values
3838
void ButtonSet::initPositions()
3939
{
40-
for (vector<Button>::size_type i = 0; i != buttons.size () ; i++)
41-
positions.fillPos (buttons[i].getButtonShape ().getOrigLoop (), buttons[i].getButtonShape ().getOrigRow ());
40+
for (vector<Button>::size_type i = 0; i != buttons.size(); i++)
41+
positions.fillPos(buttons[i].getButtonShape().getOrigLoop(), buttons[i].getButtonShape().getOrigRow());
4242
}
4343

4444
//ValidChars and Buttons will already be sorted wrt frequency
4545
//Simply merge them in order
46-
void ButtonSet::mergeButtons ()
46+
void ButtonSet::mergeButtons()
4747
{
48-
for (vector<Button>::size_type i = 0; i != buttons.size () ; i++)
49-
buttons[i].getButtonShape ().mergeRadially (positions);
50-
for (vector<Button>::size_type i = 0; i != buttons.size () ; i++)
51-
buttons[i].getButtonShape ().mergeLaterally (positions,firstPhase);
52-
for (vector<Button>::size_type i = 0; i != buttons.size () ; i++)
53-
buttons[i].getButtonShape ().mergeLaterally (positions,secondPhase);
54-
for (vector<Button>::size_type i = 0; i != buttons.size () ; i++)
55-
buttons[i].getButtonShape ().mergeLaterally (positions,thirdPhase);
48+
for (vector<Button>::size_type i = 0; i != buttons.size(); i++)
49+
buttons[i].getButtonShape().mergeRadially(positions);
50+
for (vector<Button>::size_type i = 0; i != buttons.size(); i++)
51+
buttons[i].getButtonShape().mergeLaterally(positions, firstPhase);
52+
for (vector<Button>::size_type i = 0; i != buttons.size(); i++)
53+
buttons[i].getButtonShape().mergeLaterally(positions, secondPhase);
54+
for (vector<Button>::size_type i = 0; i != buttons.size(); i++)
55+
buttons[i].getButtonShape().mergeLaterally(positions, thirdPhase);
5656

5757
}
5858
vector<Button>& ButtonSet::getButtons()
5959
{
6060
return buttons;
6161
}
6262

63-
bool ButtonSet::getButtonWithField (int inpLoop, int inpRow, Button& but)
63+
bool ButtonSet::getButtonWithField(int inpLoop, int inpRow, Button& but)
6464
{
6565
for (vector<Button>::size_type i = 0; i < buttons.size(); i++)
6666
{

source/DiskPart.h

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "enums.h"
66

77
//Holds the geometric aspects of a button
8-
class DiskPart
8+
class DiskPart
99
{
1010
//Both innerRing and outerRing can take values [0,4]
1111
//0 is the middle point, 1-2-3 are the next outer rings, 4 is the ring outside the screen
@@ -20,26 +20,26 @@ class DiskPart
2020
int loop, row;
2121

2222
public:
23-
DiskPart ();
24-
DiskPart (int inpLoop, int inpRow);
25-
int getOrigLoop () const;
26-
int getOrigRow () const;
27-
void mergeRadially (PosChart &positions);
28-
void mergeLaterally (PosChart &positions, lateralMergePhases ph);
29-
void getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd);
30-
bool isInDisk (int inpLoop, int inpRow);
23+
DiskPart();
24+
DiskPart(int inpLoop, int inpRow);
25+
int getOrigLoop() const;
26+
int getOrigRow() const;
27+
void mergeRadially(PosChart &positions);
28+
void mergeLaterally(PosChart &positions, lateralMergePhases ph);
29+
void getShape(int &loopStart, int &loopEnd, int &rowStart, int &rowEnd);
30+
bool isInDisk(int inpLoop, int inpRow);
3131
};
3232

33-
DiskPart::DiskPart ()
33+
DiskPart::DiskPart()
3434
{
3535
}
36-
DiskPart::DiskPart (int inpLoop, int inpRow)
36+
DiskPart::DiskPart(int inpLoop, int inpRow)
3737
{
3838
loop = inpLoop;
3939
row = inpRow;
4040

4141
innerRing = loop;
42-
outerRing = loop+1;
42+
outerRing = loop + 1;
4343

4444
if (loop == 0)
4545
{
@@ -58,35 +58,35 @@ DiskPart::DiskPart (int inpLoop, int inpRow)
5858
}
5959
}
6060

61-
int DiskPart::getOrigLoop () const
61+
int DiskPart::getOrigLoop() const
6262
{
6363
return loop;
6464
}
65-
int DiskPart::getOrigRow () const
65+
int DiskPart::getOrigRow() const
6666
{
6767
return row;
6868
}
6969

7070

7171
//This is the merge that will happen first.
72-
void DiskPart::mergeRadially (PosChart &positions)
72+
void DiskPart::mergeRadially(PosChart &positions)
7373
{
7474
switch (loop)
7575
{
7676
case 0:
7777
//middle loop cannot merge radially
7878
break;
7979
case 1:
80-
if (positions.getLoop (2)[row]==0)
80+
if (positions.getLoop(2)[row] == 0)
8181
{
82-
positions.fillPos (2, row);
82+
positions.fillPos(2, row);
8383
outerRing = 3;
8484
}
8585
break;
8686
case 2:
87-
if (positions.getLoop (1)[row]==0)
87+
if (positions.getLoop(1)[row] == 0)
8888
{
89-
positions.fillPos (1, row);
89+
positions.fillPos(1, row);
9090
innerRing = 1;
9191
}
9292
break;
@@ -97,7 +97,7 @@ void DiskPart::mergeRadially (PosChart &positions)
9797
//First phase merges non-radially-merged buttons (ccw).
9898
//Second phase merges radially-merged buttons (ccw).
9999
//Third phase merges any remaining empty spaces (cw).
100-
void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
100+
void DiskPart::mergeLaterally(PosChart &positions, lateralMergePhases ph)
101101
{
102102
switch (ph)
103103
{
@@ -109,18 +109,18 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
109109
if (loop == 0)
110110
{
111111
//the first loop has only two buttons
112-
if (positions.getLoop (loop)[(row + 1) % 2] == 0)
112+
if (positions.getLoop(loop)[(row + 1) % 2] == 0)
113113
{
114-
positions.fillPos (loop, (row + 1) % 2);
114+
positions.fillPos(loop, (row + 1) % 2);
115115
startSlice = stopSlice = 0;
116116
}
117117
}
118118
else
119119
{
120120
//other loops have 12 buttons
121-
if (positions.getLoop (loop)[(row + 1) % 12] == 0)
121+
if (positions.getLoop(loop)[(row + 1) % 12] == 0)
122122
{
123-
positions.fillPos (loop, (row + 1) % 12);
123+
positions.fillPos(loop, (row + 1) % 12);
124124
stopSlice = (row + 2) % 12;
125125
}
126126
}
@@ -133,12 +133,12 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
133133
if (outerRing - innerRing == 2)
134134
{
135135
//check if both nearby positions are available
136-
if ((positions.getLoop (1)[(row + 1) % 12] == 0) && (positions.getLoop (2)[(row + 1) % 12] == 0))
137-
{
138-
positions.fillPos (1, (row + 1) % 12);
139-
positions.fillPos (2, (row + 1) % 12);
140-
stopSlice = (row + 2) % 12;
141-
}
136+
if ((positions.getLoop(1)[(row + 1) % 12] == 0) && (positions.getLoop(2)[(row + 1) % 12] == 0))
137+
{
138+
positions.fillPos(1, (row + 1) % 12);
139+
positions.fillPos(2, (row + 1) % 12);
140+
stopSlice = (row + 2) % 12;
141+
}
142142
}
143143
break;
144144

@@ -149,35 +149,35 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
149149
//don't need to merge middle again
150150
if (loop != 0)
151151
{
152-
if (positions.getLoop (loop)[(row + 11) % 12] == 0)
152+
if (positions.getLoop(loop)[(row + 11) % 12] == 0)
153153
{
154-
positions.fillPos (loop, (row + 11) % 12);
154+
positions.fillPos(loop, (row + 11) % 12);
155155
startSlice = (row + 11) % 12;
156156
}
157157
}
158158
}
159159
else if (outerRing - innerRing == 2)
160160
{
161-
if ((positions.getLoop (1)[(row + 11) % 12] == 0) && (positions.getLoop (2)[(row + 11) % 12] == 0))
162-
{
163-
positions.fillPos (1, (row + 11) % 12);
164-
positions.fillPos (2, (row + 11) % 12);
165-
startSlice = (row + 11) % 12;
166-
}
161+
if ((positions.getLoop(1)[(row + 11) % 12] == 0) && (positions.getLoop(2)[(row + 11) % 12] == 0))
162+
{
163+
positions.fillPos(1, (row + 11) % 12);
164+
positions.fillPos(2, (row + 11) % 12);
165+
startSlice = (row + 11) % 12;
166+
}
167167
}
168168
break;
169169
}
170170
}
171171

172-
void DiskPart::getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd)
172+
void DiskPart::getShape(int &loopStart, int &loopEnd, int &rowStart, int &rowEnd)
173173
{
174174
loopStart = innerRing;
175175
loopEnd = outerRing;
176176
rowStart = startSlice;
177177
rowEnd = stopSlice;
178178
}
179179

180-
bool DiskPart::isInDisk (int inpLoop, int inpRow)
180+
bool DiskPart::isInDisk(int inpLoop, int inpRow)
181181
{
182182
switch (inpLoop)
183183
{

0 commit comments

Comments
 (0)