void EnsureCapacity(TContainer& container, typename TContainer::size_type index)
 {
     // if we need to resize
     if(container.size() <= index)
     {
         // then we shall resize!
         container.resize(index + 1);
     }
 }
Example #2
0
 friend typename TContainer::template rebind<result_of<TRecord>>::type select(const TContainer& recs, const select_query& q)
 {
   using TReturnContainer = typename TContainer::template rebind<result_of<TRecord> >::type;
   TReturnContainer ret;
   ret.reserve(recs.size());
   for(const TRecord& cur : recs) {
     ret.push_back(select(cur, q));
   }
   return ret;
 }
Example #3
0
  static QStringList toQStringList(TContainer inContainer)
  {
    QStringList outContainer;

    for (size_t index=0; index < inContainer.size(); ++index)
    {
      outContainer.append(QString::number(inContainer.at(index)));
    }

    return outContainer;
  };
Example #4
0
inline
std::vector<std::shared_ptr<TContainer> >
split(TContainer & container, std::size_t const PARTS)
{
  std::vector<std::shared_ptr<TContainer> > split_container;
  split_container.resize(PARTS);
  std::size_t const container_original_size = container.size();

  for (long i = static_cast<long>(PARTS) - 1; i >= 0; --i)
  {
    std::size_t const part_size = container_original_size / PARTS +
                                  (container_original_size % PARTS > static_cast<std::size_t>(i));
    split_container[i] =
      std::make_shared<TContainer>(std::make_move_iterator(std::next(container.end(), -part_size)),
                                   std::make_move_iterator(container.end())
                                   );

    // Make sure the container is smaller now
    if (container.size() > i * (container_original_size / PARTS + 1))
      container.resize(i * (container_original_size / PARTS + 1));
  }

  return split_container;
}
Example #5
0
hash_t Pearson_Compare(const TContainer& data)
{
  hash_t hash;
  hash.fill(0);

  for (size_t j = 0; j < HASH_SIZE; ++j)
  {
    uint8_t subhash = etl::PEARSON_LOOKUP[(data[0] + j) % 256];

    for (size_t i = 1; i < data.size(); ++i)
    {
      subhash = etl::PEARSON_LOOKUP[subhash ^ data[i]];
    }

    hash[j] = subhash;
  }

  return hash;
}
Example #6
0
jobjectArray ToJavaArray(JNIEnv * env, jclass clazz, TContainer const & src, TToJavaFn && toJavaFn)
{
  return ToJavaArray(env, clazz, begin(src), end(src), src.size(), forward<TToJavaFn>(toJavaFn));
}