Commit 62cd2d36 authored by kolusask's avatar kolusask
Browse files

Pass ArrayView instead of pointer to HashGraph

parent f7744e77
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -12,9 +12,9 @@ HashGraphMap<HG, K, V, Device>::HashGraphMap(const Array<Pair<K, V>, Device>& va

template<template<class, class, class> class HG, typename K, typename V, typename Device>
bool HashGraphMap<HG, K, V, Device>::find(const K& key, V& value) const {
    Pair<K, V> pair;
    if (HG<Pair<K, V>, K, Device>::find(key, &pair)) {
        value = pair.value;
    Array<Pair<K, V>, Device> item(1);
    if (HG<Pair<K, V>, K, Device>::find(key, item.getView())) {
        value = item.getElement(0).value;
        return true;
    }
    return false;
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ HashGraphSet<HG, T, Device>::HashGraphSet(const Array<T, Device>& values) : HG<V

template<template<class, class, class> class HG, typename T, typename Device>
bool HashGraphSet<HG, T, Device>::contains(const T& value) const {
    return HG<Value<T>, T, Device>::find(value);
    Array<Value<T>, Device> item(1);
    return HG<Value<T>, T, Device>::find(value, item.getView());
}


+10 −1
Original line number Diff line number Diff line
@@ -21,12 +21,21 @@ class HashGraphV1 {
                                     ArrayView<int, Device>, ArrayView<int, Device>);

  public:
    void debug_print() const {
      std::cout << "CONTENT" << std::endl;
      std::cout << m_content << std::endl;
      std::cout << "ITEMS" << std::endl;
      std::cout << m_items << std::endl;
      std::cout << "OFFSET" << std::endl;
      std::cout << m_offset << std::endl;
      
    }
    int duplicates() const;

  protected:
    HashGraphV1(const Array<Item, Device>& items);
    ~HashGraphV1();
    bool find(const Key& key, Item* item = nullptr) const;
    bool find(const Key& key, ArrayView<Item, Device> item) const;

  private:
    Array<Item, Device> m_content;
+1 −1
Original line number Diff line number Diff line
@@ -47,6 +47,6 @@ int HashGraphV1<Item, Key, Device>::duplicates() const {
}

template<typename Item, typename Key, typename Device>
bool HashGraphV1<Item, Key, Device>::find(const Key& key, Item* item) const {
bool HashGraphV1<Item, Key, Device>::find(const Key& key, ArrayView<Item, Device> item) const {
    return m_view->find(key, item);
}
+3 −2
Original line number Diff line number Diff line
@@ -26,14 +26,15 @@ class HashGraphV1View {
    ~HashGraphV1View();
    int duplicates() const;

    bool find(const Key& key, Item* item = nullptr) const;
    bool find(const Key& key, ArrayView<Item, Device> item) const;

    void build(const typename Array<Item, Device>::ConstViewType items,
               ArrayView<int, Device> hashes,
               ArrayView<int, Device> counter);

  private:
    void fill_offset(const ArrayView<int, Device>& counter);

  private:
    ArrayView<Item, Device> place_items();

    ArrayView<Item, Device> m_content;