Commit 6b6ca175 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Fix minor bugs for 4 extra tests to pass.

	* mln/core/site_set/operators.hh
	(include): Remove dependency to set::card; it was cycling.
	Remove temporary util::yes.
	* mln/metal/ref.hh: Fix guard.
	* mln/io/abort.hh: Add std::.
	* mln/io/pnm/load_header.hh: Add std::.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3081 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent e6bb2006
2008-12-23 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Fix minor bugs for 4 extra tests to pass.
* mln/core/site_set/operators.hh
(include): Remove dependency to set::card; it was cycling.
Remove temporary util::yes.
* mln/metal/ref.hh: Fix guard.
* mln/io/abort.hh: Add std::.
* mln/io/pnm/load_header.hh: Add std::.
2008-12-23 Thierry Geraud <thierry.geraud@lrde.epita.fr>
 
Rename mln::clone as mln::duplicate.
......@@ -33,14 +33,11 @@
///
/// Definition of operators on mln::Site_Set.
///
/// \todo Re-vamp this file now!
/// \todo Fix code for multi-sets.
# include <algorithm>
# include <mln/core/concept/site_set.hh>
# include <mln/set/card.hh>
# include <mln/util/yes.hh> // Temporary include.
......@@ -159,6 +156,37 @@ namespace mln
util::ord<P>());
}
// card.
template <typename S>
inline
unsigned set_card_dispatch_(mln::trait::site_set::nsites::any,
const S& s)
{
unsigned n = 0;
mln_piter(S) p(s);
for_all(p)
++n;
return n;
}
template <typename S>
inline
unsigned set_card_dispatch_(mln::trait::site_set::nsites::known,
const S& s)
{
return s.nsites();
}
template <typename S>
inline
unsigned set_card(const Site_Set<S>& s)
{
return set_card_dispatch_(mln_trait_site_set_nsites(S)(),
exact(s));
}
} // end of namespace mln::internal
......@@ -187,7 +215,7 @@ namespace mln
operator_equal_uniques(const Site_Set<Sl>& lhs,
const Site_Set<Sr>& rhs)
{
if (set::card(lhs) != set::card(rhs))
if (internal::set_card(lhs) != internal::set_card(rhs))
return false;
return mln::internal::sym_diff_std_set(lhs, rhs).empty();
}
......@@ -198,7 +226,7 @@ namespace mln
operator_equal_unique_multiple(const Site_Set<Sl>& lhs,
const Site_Set<Sr>& rhs)
{
if (set::card(lhs) != set::card(rhs))
if (internal::set_card(lhs) != internal::set_card(rhs))
return false;
return mln::internal::to_std_set(lhs) == mln::internal::to_std_set(rhs);
}
......@@ -210,7 +238,7 @@ namespace mln
const Site_Set<Sr>& rhs)
{
// FIXME: Approximate code...
if (set::card(lhs) != set::card(rhs))
if (internal::set_card(lhs) != internal::set_card(rhs))
return false;
return mln::internal::to_std_set(lhs) == mln::internal::to_std_set(rhs);
}
......@@ -231,7 +259,7 @@ namespace mln
if (lhs.is_empty())
return true; // We have "empty set < a non empty set".
// From here, both lhs and rhs are not empty.
if (set::card(lhs) >= set::card(rhs))
if (internal::set_card(lhs) >= internal::set_card(rhs))
return false;
return lhs.crop_wrt(rhs) == lhs;
}
......@@ -242,7 +270,7 @@ namespace mln
operator_less_uniques(const Site_Set<Sl>& lhs,
const Site_Set<Sr>& rhs)
{
if (set::card(lhs) >= set::card(rhs))
if (internal::set_card(lhs) >= internal::set_card(rhs))
return false;
return mln::internal::leq_std_set(lhs, rhs);
}
......@@ -253,7 +281,7 @@ namespace mln
operator_less_unique_multiple(const Site_Set<Sl>& lhs,
const Site_Set<Sr>& rhs)
{
if (set::card(lhs) >= set::card(rhs))
if (internal::set_card(lhs) >= internal::set_card(rhs))
return false;
return mln::internal::leq_std_set(lhs, rhs);
}
......@@ -265,7 +293,7 @@ namespace mln
const Site_Set<Sr>& rhs)
{
// FIXME: Approximate code...
if (set::card(lhs) >= set::card(rhs))
if (internal::set_card(lhs) >= internal::set_card(rhs))
return false;
return mln::internal::leq_std_set(lhs, rhs);
}
......@@ -464,7 +492,7 @@ namespace mln
operator<=(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs)
{
mlc_equal(mln_site(Sl), mln_site(Sr))::check();
if (set::card(lhs) > set::card(rhs))
if (internal::set_card(lhs) > internal::set_card(rhs))
return false;
return lhs < rhs || lhs == rhs;
}
......
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
// Research and Development Laboratory
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
// Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -29,14 +29,13 @@
#ifndef MLN_IO_ABORT_HH
# define MLN_IO_ABORT_HH
/*!
* \file mln/io/abort.hh
*
* \brief Define a function which aborts a process in io module.
*
*/
/// \file mln/io/abort.hh
///
/// Define a function which aborts a process in io module.
# include <iostream>
# include <cstdlib>
namespace mln
{
......@@ -49,13 +48,14 @@ namespace mln
/// The way to abort when an error occur in io processing.
void abort();
# ifndef MLN_INCLUDE_ONLY
inline
void abort()
{
std::cerr << "I/O error, aborting." << std::endl;
exit(0);
std::exit(0);
}
# endif // ! MLN_INCLUDE_ONLY
......
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
// Research and Development Laboratory
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
// Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -29,17 +29,16 @@
#ifndef MLN_IO_PNM_LOAD_HEADER_HH
# define MLN_IO_PNM_LOAD_HEADER_HH
/*!
* \file mln/io/pnm/load_header.hh
*
* \brief Define a function which loads header for PNM image.
*
*/
/// \file mln/io/pnm/load_header.hh
///
/// Define a function which loads header for PNM image.
# include <cstdlib>
# include <iostream>
# include <fstream>
# include <string>
namespace mln
{
......@@ -95,7 +94,7 @@ namespace mln
if (! test)
{
std::cerr << "error: badly formed header!";
abort();
std::abort();
}
return false;
}
......@@ -114,7 +113,7 @@ namespace mln
<< "expected P" << ascii
<< " or P" << raw
<< ", get P" << type << "!";
abort();
std::abort();
}
}
......
......@@ -27,9 +27,9 @@
// Public License.
#ifndef MLN_METAL_REF_HH
# define MLN_METAL_RFE_HH
# define MLN_METAL_REF_HH
/// \file mln/metal/ref.hh
/// \file mln/metal/ref.hh
///
/// FIXME.
......
Supports Markdown
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