Skip to content

Commit

Permalink
fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoang29 committed Jan 28, 2016
1 parent 4424dbd commit ff377b2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions vowpalwabbit/ezexample.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ class ezexample
ec = this_ec;
we_create_ec = false;

for (unsigned char*i=ec->indices.begin; i != ec->indices.end; ++i)
{ current_ns = *i;
ns_exists[(int)current_ns] = true;
}
for (auto ns : ec->indices)
ns_exists[ns] = true;
if (current_ns != 0)
{ str[0] = current_ns;
current_seed = VW::hash_space(*vw_ref, str);
Expand All @@ -120,11 +118,11 @@ class ezexample
~ezexample() // calls finish_example *only* if we created our own example!
{ if (ec->in_use && VW::is_ring_example(*vw_par_ref, ec))
VW::finish_example(*vw_par_ref, ec);
for (example**ecc=example_copies.begin; ecc!=example_copies.end; ecc++)
if ((*ecc)->in_use && VW::is_ring_example(*vw_par_ref, ec))
VW::finish_example(*vw_par_ref, *ecc);
for (auto ecc : example_copies)
if (ecc->in_use && VW::is_ring_example(*vw_par_ref, ec))
VW::finish_example(*vw_par_ref, ecc);
example_copies.erase();
free(example_copies.begin);
free(example_copies.begin());
}

bool ensure_ns_exists(char c) // returns TRUE iff we should ignore it :)
Expand Down Expand Up @@ -273,9 +271,9 @@ class ezexample
{ static example* empty_example = is_multiline ? VW::read_example(*vw_par_ref, (char*)"") : nullptr;
if (is_multiline)
{ vw_ref->learn(empty_example);
for (example**ecc=example_copies.begin; ecc!=example_copies.end; ecc++)
if ((*ecc)->in_use)
VW::finish_example(*vw_par_ref, *ecc);
for (auto ecc : example_copies)
if (ecc->in_use)
VW::finish_example(*vw_par_ref, ecc);
example_copies.erase();
}
}
Expand Down

0 comments on commit ff377b2

Please sign in to comment.