Professional Documents
Culture Documents
//----------------------------------------------------------------------
}
//----------------------------------------------------------------------
}
int getSize() {
if (isEmpty()) {
return 0;
}
Node q = head;
int count = 0;
while (q != null) {
q = q.next;
count++;
}
return count;
}
void sortAsc() {
if (isEmpty()) {
return;
}
for (int i = 0; i <= getSize(); i++) {
Node q = takeNodeAtPosition(i);
for (int j = i + 1; j <= getSize(); j++) {
Node p = takeNodeAtPosition(j);
if (q.info.color > p.info.color) {
Bike temp = q.info;
q.info = p.info;
p.info = temp;
}
}
}
}
void sortDesc() {
if (isEmpty()) {
return;
}
for (int i = 0; i <= getSize(); i++) {
Node q = takeNodeAtPosition(i);
for (int j = i + 1; j <= getSize(); j++) {
Node p = takeNodeAtPosition(j);
if (q.info.color < p.info.color) {
Bike temp = q.info;
q.info = p.info;
p.info = temp;
}
}
}
}
Node NodeMax() {
if (isEmpty()) {
return null;
}
Node q = head;
Node max = head;
while (q != null) {
if (q.info.color > max.info.color) {
max = q;
}
q = q.next;
}
return max;
}
Node findMinNode() {
if (isEmpty()) {
return null;
}
Node min = head;
Node q = head;
while (q != null) {
if (min.info.color > q.info.color) {
min = q;
}
q = q.next;
}
return min;
}