Neighbor with highest numbered arfcn was usually discarded

from neighbor table.
This commit is contained in:
Michael Iedema
2016-07-26 11:10:06 -07:00
parent 303b080e67
commit a716ed66c0

View File

@@ -545,7 +545,7 @@ static void uniquify(vector<T> &vec)
{ {
if (vec.size() < 2) return; if (vec.size() < 2) return;
unsigned i = 0, j = 1; unsigned i = 0, j = 1;
while (j < vec.size()-1) { while (j < vec.size()) { // (pat 10-17-2014) was: (j<vec.size()-1)
if (vec[i] != vec[j]) { if (vec[i] != vec[j]) {
i++; i++;
if (i != j) { vec[i] = vec[j]; } if (i != j) { vec[i] = vec[j]; }
@@ -605,7 +605,7 @@ std::vector<unsigned> NeighborTable::getARFCNs() const
// Eliminate duplicate ARFCNs. // Eliminate duplicate ARFCNs.
uniquify(bcchChannelList); uniquify(bcchChannelList);
// If first element is ARFCN 0, move it to the back. // If first element is ARFCN 0, move it to the back. This required by the spec.
if (bcchChannelList.size() >= 2 && bcchChannelList[0] == 0) { if (bcchChannelList.size() >= 2 && bcchChannelList[0] == 0) {
rollLeft(bcchChannelList); rollLeft(bcchChannelList);
} }
@@ -682,6 +682,21 @@ bool NeighborTable::neighborCongestion(unsigned arfcn, unsigned bsic)
return false; return false;
} }
static void run1test(vector<int> &foo)
{
for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it);
printf("\n");
sort(foo.begin(),foo.end());
printf("after sort: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it);
printf("\n");
uniquify(foo);
printf("after uniquify: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it);
printf("\n");
rollLeft(foo);
printf("after rollLeft: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it);
printf("\n");
}
static void runSomeTests() static void runSomeTests()
{ {
vector<int> foo; vector<int> foo;
@@ -697,16 +712,19 @@ static void runSomeTests()
foo.push_back(2); foo.push_back(2);
foo.push_back(0); foo.push_back(0);
for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it); run1test(foo);
printf("\n");
sort(foo.begin(),foo.end()); foo.clear();
printf("after sort: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it); foo.push_back(19);
printf("\n"); foo.push_back(19);
uniquify(foo); run1test(foo);
printf("after uniquify: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it);
printf("\n"); foo.clear();
rollLeft(foo); foo.push_back(1);
printf("after rollLeft: "); for (vector<int>::iterator it = foo.begin(); it != foo.end(); it++) printf("%d ",*it); foo.push_back(2);
printf("\n"); run1test(foo);
foo.clear();
foo.push_back(1);
run1test(foo);
} }