Further improvements on Accesspoints class

Only go through the whole list again if needed
This commit is contained in:
Stefan Kremser
2018-03-29 16:40:23 +02:00
parent 36bd59f5cd
commit 7bd14a6bda
2 changed files with 9 additions and 10 deletions

View File

@@ -14,10 +14,10 @@ void Accesspoints::sort() {
int c = listSize; int c = listSize;
while(c--){ while(c--){
for(int i = 1; i <= c; i++){ for(int i = 1; i <= c; i++){
aAP = getAP(i-2); aAP = getAP(i-2); // prev
bAP = getAP(i-1); bAP = aAP ? aAP->next : getAP(i-1); // to be compared
cAP = getAP(i); cAP = bAP ? bAP->next : getAP(i); // to be compared
dAP = getAP(i+1); dAP = cAP ? cAP->next : getAP(i+1); // next
// a -> b -> c -> d // a -> b -> c -> d
@@ -52,9 +52,9 @@ void Accesspoints::sortAfterChannel() {
while(c--){ while(c--){
for(int i = 1; i <= c; i++){ for(int i = 1; i <= c; i++){
aAP = getAP(i-2); aAP = getAP(i-2);
bAP = getAP(i-1); bAP = aAP ? aAP->next : getAP(i-1);
cAP = getAP(i); cAP = bAP ? bAP->next : getAP(i);
dAP = getAP(i+1); dAP = cAP ? cAP->next : getAP(i+1);
if(WiFi.channel(bAP->id) > WiFi.channel(cAP->id)) { if(WiFi.channel(bAP->id) > WiFi.channel(cAP->id)) {
cAP->next = bAP; cAP->next = bAP;
@@ -349,8 +349,8 @@ void Accesspoints::internal_deselect(int num) {
void Accesspoints::internal_remove(int num) { void Accesspoints::internal_remove(int num) {
AP* aAP = getAP(num-1); // prev AP* aAP = getAP(num-1); // prev
AP* bAP = getAP(num); // to-delete AP* bAP = aAP ? aAP->next : getAP(num); // to-delete
AP* cAP = getAP(num+1); // next AP* cAP = bAP ? bAP->next : getAP(num+1); // next
if(aAP && cAP) { // a -> b -> c = a -> c if(aAP && cAP) { // a -> b -> c = a -> c
aAP->next = cAP; // aAP->next = cAP; //

View File

@@ -3,7 +3,6 @@
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <LinkedList.h>
#include "Names.h" #include "Names.h"
#include "language.h" #include "language.h"