Commit b5cf3e3b authored by Roy Macdonald's avatar Roy Macdonald Committed by Davis E. King

Fixes issue with object named nil that collide with apple's definition. (#537)

* Fixes issue with object named nil that collide with apple's definition.

* fix nil named objects: changed name to no_parent
parent a23d726b
...@@ -162,9 +162,9 @@ namespace dlib ...@@ -162,9 +162,9 @@ namespace dlib
g.set_label(sink_node, SINK_CUT); g.set_label(sink_node, SINK_CUT);
// used to indicate "no parent" // used to indicate "no parent"
const unsigned long nil = g.number_of_nodes(); const unsigned long no_parent = g.number_of_nodes();
parent.assign(g.number_of_nodes(), nil); parent.assign(g.number_of_nodes(), no_parent);
time = 1; time = 1;
dist.assign(g.number_of_nodes(), 0); dist.assign(g.number_of_nodes(), 0);
...@@ -194,14 +194,14 @@ namespace dlib ...@@ -194,14 +194,14 @@ namespace dlib
private: private:
unsigned long distance_to_origin ( unsigned long distance_to_origin (
const unsigned long nil, const unsigned long no_parent,
unsigned long p, unsigned long p,
unsigned long unsigned long
) const ) const
{ {
unsigned long start = p; unsigned long start = p;
unsigned long count = 0; unsigned long count = 0;
while (p != nil) while (p != no_parent)
{ {
if (ts[p] == time) if (ts[p] == time)
{ {
...@@ -237,7 +237,7 @@ namespace dlib ...@@ -237,7 +237,7 @@ namespace dlib
typedef typename flow_graph::in_edge_iterator in_edge_iterator; typedef typename flow_graph::in_edge_iterator in_edge_iterator;
// used to indicate "no parent" // used to indicate "no parent"
const unsigned long nil = g.number_of_nodes(); const unsigned long no_parent = g.number_of_nodes();
while (orphans.size() > 0) while (orphans.size() > 0)
{ {
...@@ -260,7 +260,7 @@ namespace dlib ...@@ -260,7 +260,7 @@ namespace dlib
if (g.get_label(id) != label_p || g.get_flow(q) <= 0 ) if (g.get_label(id) != label_p || g.get_flow(q) <= 0 )
continue; continue;
unsigned long temp = distance_to_origin(nil, id,source); unsigned long temp = distance_to_origin(no_parent, id,source);
if (temp < best_dist) if (temp < best_dist)
{ {
best_dist = temp; best_dist = temp;
...@@ -276,7 +276,7 @@ namespace dlib ...@@ -276,7 +276,7 @@ namespace dlib
} }
// if we didn't find a parent for p // if we didn't find a parent for p
if (parent[p] == nil) if (parent[p] == no_parent)
{ {
for(in_edge_iterator q = begin; q != end; ++q) for(in_edge_iterator q = begin; q != end; ++q)
{ {
...@@ -290,7 +290,7 @@ namespace dlib ...@@ -290,7 +290,7 @@ namespace dlib
if (parent[id] == p) if (parent[id] == p)
{ {
parent[id] = nil; parent[id] = no_parent;
orphans.push_back(id); orphans.push_back(id);
} }
} }
...@@ -309,7 +309,7 @@ namespace dlib ...@@ -309,7 +309,7 @@ namespace dlib
if (g.get_label(id) != label_p || g.get_flow(q) <= 0) if (g.get_label(id) != label_p || g.get_flow(q) <= 0)
continue; continue;
unsigned long temp = distance_to_origin(nil, id,sink); unsigned long temp = distance_to_origin(no_parent, id,sink);
if (temp < best_dist) if (temp < best_dist)
{ {
...@@ -326,7 +326,7 @@ namespace dlib ...@@ -326,7 +326,7 @@ namespace dlib
} }
// if we didn't find a parent for p // if we didn't find a parent for p
if (parent[p] == nil) if (parent[p] == no_parent)
{ {
for(out_edge_iterator q = begin; q != end; ++q) for(out_edge_iterator q = begin; q != end; ++q)
{ {
...@@ -340,7 +340,7 @@ namespace dlib ...@@ -340,7 +340,7 @@ namespace dlib
if (parent[id] == p) if (parent[id] == p)
{ {
parent[id] = nil; parent[id] = no_parent;
orphans.push_back(id); orphans.push_back(id);
} }
} }
...@@ -366,7 +366,7 @@ namespace dlib ...@@ -366,7 +366,7 @@ namespace dlib
typedef typename flow_graph::edge_type edge_type; typedef typename flow_graph::edge_type edge_type;
// used to indicate "no parent" // used to indicate "no parent"
const unsigned long nil = g.number_of_nodes(); const unsigned long no_parent = g.number_of_nodes();
unsigned long s = source_side; unsigned long s = source_side;
unsigned long t = sink_side; unsigned long t = sink_side;
...@@ -414,7 +414,7 @@ namespace dlib ...@@ -414,7 +414,7 @@ namespace dlib
g.adjust_flow(t,s, min_cap); g.adjust_flow(t,s, min_cap);
if (g.get_flow(s,t) <= 0) if (g.get_flow(s,t) <= 0)
{ {
parent[t] = nil; parent[t] = no_parent;
orphans.push_back(t); orphans.push_back(t);
} }
...@@ -429,7 +429,7 @@ namespace dlib ...@@ -429,7 +429,7 @@ namespace dlib
g.adjust_flow(t,s, min_cap); g.adjust_flow(t,s, min_cap);
if (g.get_flow(s,t) <= 0) if (g.get_flow(s,t) <= 0)
{ {
parent[s] = nil; parent[s] = no_parent;
orphans.push_back(s); orphans.push_back(s);
} }
s = t; s = t;
......
...@@ -42,12 +42,12 @@ namespace dlib ...@@ -42,12 +42,12 @@ namespace dlib
integer info = 0; integer info = 0;
char sort = 'N'; char sort = 'N';
L_fp fnil = 0; L_fp fnil = 0;
logical nil = 0; logical bwork = 0;
integer sdim = 0; integer sdim = 0;
DLIB_FORTRAN_ID(dgees)(&jobvs, &sort, fnil, &n, DLIB_FORTRAN_ID(dgees)(&jobvs, &sort, fnil, &n,
a, &lda, &sdim, wr, a, &lda, &sdim, wr,
wi, vs, &ldvs, work, wi, vs, &ldvs, work,
&lwork, &nil, &info); &lwork, &bwork, &info);
return info; return info;
} }
...@@ -61,12 +61,12 @@ namespace dlib ...@@ -61,12 +61,12 @@ namespace dlib
integer info = 0; integer info = 0;
char sort = 'N'; char sort = 'N';
L_fp fnil = 0; L_fp fnil = 0;
logical nil = 0; logical bwork = 0;
integer sdim = 0; integer sdim = 0;
DLIB_FORTRAN_ID(sgees)(&jobvs, &sort, fnil, &n, DLIB_FORTRAN_ID(sgees)(&jobvs, &sort, fnil, &n,
a, &lda, &sdim, wr, a, &lda, &sdim, wr,
wi, vs, &ldvs, work, wi, vs, &ldvs, work,
&lwork, &nil, &info); &lwork, &bwork, &info);
return info; return info;
} }
......
...@@ -18,7 +18,7 @@ namespace ...@@ -18,7 +18,7 @@ namespace
logger dlog("test.tuple"); logger dlog("test.tuple");
struct nil struct s_nil
{ {
template <typename T> template <typename T>
void operator() ( void operator() (
...@@ -122,10 +122,10 @@ namespace ...@@ -122,10 +122,10 @@ namespace
b = a; b = a;
inc i; inc i;
nil n; s_nil n;
a.for_each(inc()); a.for_each(inc());
a.for_each(i); a.for_each(i);
const_cast<const T&>(a).for_each(nil()); const_cast<const T&>(a).for_each(s_nil());
const_cast<const T&>(a).for_each(n); const_cast<const T&>(a).for_each(n);
DLIB_TEST(a.get<0>() == b.get<0>()+2); DLIB_TEST(a.get<0>() == b.get<0>()+2);
...@@ -145,7 +145,7 @@ namespace ...@@ -145,7 +145,7 @@ namespace
a.for_index(i,0); a.for_index(i,0);
a.for_index(inc(),1); a.for_index(inc(),1);
const_cast<const T&>(a).for_index(n,2); const_cast<const T&>(a).for_index(n,2);
const_cast<const T&>(a).for_index(nil(),0); const_cast<const T&>(a).for_index(s_nil(),0);
DLIB_TEST(a.get<0>() == b.get<0>()+1); DLIB_TEST(a.get<0>() == b.get<0>()+1);
DLIB_TEST(a.get<1>() == b.get<1>()+1); DLIB_TEST(a.get<1>() == b.get<1>()+1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment