Commit b7e3ad46 authored by Yaroslav's avatar Yaroslav

Added files

parent 9534189f
File added
File added
File added
/*
* CellListIt.hpp
*
* Created on: May 18, 2016
* Author: Yaroslav Zaluzhnyi
*/
#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_
#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_
template<typename T>
class Cell_list_iterator
{
private:
T & NN;
// Cells counter
size_t cell_count;
// Particles counter
size_t p_count;
/*! \brief Handles incrementing of cells and particles counters
*
*/
inline void fp()
{
++p_count;
if (p_count >= NN.getNelements(NN.getKeys().get(cell_count)))
{
p_count = 0;
++cell_count;
while (cell_count < NN.getKeys().size() && NN.getNelements(NN.getKeys().get(cell_count)) == 0)
{
++cell_count;
}
}
}
public:
// Constructor
Cell_list_iterator(T & NN)
:NN(NN)
{
reset();
}
// Destructor
~Cell_list_iterator()
{
}
/*! \brief Get the next element
*
* \return cell list iterator
*
*/
inline Cell_list_iterator operator++()
{
fp();
while (isNext() && this->get() >= NN.get_gm())
{
fp();
}
return *this;
}
/*! \brief Checks if there is a next element
*
* \return true if there is the next, false otherwise
*
*/
inline bool isNext()
{
if (cell_count >= NN.getKeys().size())
{
return false;
}
return true;
}
/*! \brief Get the real particle id
*
* \return the real particle id
*
*/
inline size_t get()
{
auto cell_id = NN.getKeys().get(cell_count);
auto p = NN.get(cell_id,p_count);
return p;
}
/*! \brief Reset an iterator (set the counters to the first valid ones)
*
*/
void reset()
{
cell_count = 0;
p_count = -1;
this->operator++();
}
};
#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_ */
/*
* has_max_prop.hpp
*
* Created on: Jul 27, 2016
* Author: yaroslav
*/
#ifndef OPENFPM_DATA_SRC_PACKER_UNPACKER_HAS_MAX_PROP_HPP_
#define OPENFPM_DATA_SRC_PACKER_UNPACKER_HAS_MAX_PROP_HPP_
#include "util/common.hpp"
template<typename T, typename Sfinae = void>
struct has_max_prop_nn: std::false_type {};
/*! \brief has_max_prop check if a type has defined a member max_prop
*
* ### Example
*
* \snippet util_test.hpp Check has_max_prop
*
* return true if T::value_type::max_prop is a valid type
*
*/
template<typename T>
struct has_max_prop_nn<T, typename Void<decltype( T::max_prop )>::type> : std::true_type
{};
template<typename T, bool has_max_prop>
struct max_prop_nn
{
enum
{
number = T::max_prop
};
};
template<typename T>
struct max_prop_nn<T,false>
{
enum
{
number = 0
};
};
template<typename T, bool hvt>
struct has_max_prop
{
typedef has_max_prop<typename T::value_type,has_value_type< typename T::value_type >::value> hmp;
enum
{
value = hmp::value
};
enum
{
number = hmp::number
};
};
template<typename T>
struct has_max_prop<T,false>
{
enum
{
value = has_max_prop_nn<T>::value
};
enum
{
number = max_prop_nn<T,has_max_prop_nn<T>::value>::number
};
};
#endif /* OPENFPM_DATA_SRC_PACKER_UNPACKER_HAS_MAX_PROP_HPP_ */
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