Skip to content

Commit

Permalink
fix bofgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Feb 12, 2024
1 parent 1a4719b commit 0905173
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/include/bofstd/bofgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ class IdMap
public:
using iterator = typename std::vector<ElementType>::iterator;
using const_iterator = typename std::vector<ElementType>::const_iterator;
/*
const_iterator begin() const

const_iterator cbegin() const
{
return mElementCollection.begin();
}
const_iterator end() const
const_iterator cend() const
{
return mElementCollection.end();
}
/*
Span<const ElementType> Element() const
{
return mElementCollection;
Expand All @@ -179,7 +179,8 @@ class IdMap
return mElementCollection.end();
}

Span<ElementType> &Element() const
//Span<ElementType> &Element() const
std::vector<ElementType> &Element()
{
return mElementCollection;
}
Expand Down Expand Up @@ -355,7 +356,8 @@ class BofDirGraph
NodeType &Node(uint32_t _Id_U32);
const NodeType &Node(uint32_t _Id_U32) const;
Span<const uint32_t> Neighbor(uint32_t _Id_U32) const;
Span<const Edge> Edges() const;
// std::vector<typename BofDirGraph<NodeType>::Edge> &Edges();

IdMap<NodeType> &NodeMap();
IdMap<Edge> &EdgeMap();

Expand Down Expand Up @@ -407,28 +409,29 @@ IdMap<typename BofDirGraph<NodeType>::Edge> &BofDirGraph<NodeType>::EdgeMap()
{
return mEdgeCollection;
}

/*
template <typename NodeType>
std::vector<typename BofDirGraph<NodeType>::Edge> &BofDirGraph<NodeType>::Edges()
{
return mEdgeCollection.Element();
}
*/
template <typename NodeType>
Span<const uint32_t> BofDirGraph<NodeType>::Neighbor(uint32_t _Id_U32) const
{
std::lock_guard<std::mutex> Lock(mMtx);
const auto iter = mNodeNeighborCollection.Find(_Id_U32);
BOF_ASSERT(iter != mNodeNeighborCollection.end());
BOF_ASSERT(iter != mNodeNeighborCollection.cend());
return *iter;
}

template <typename NodeType>
Span<const typename BofDirGraph<NodeType>::Edge> BofDirGraph<NodeType>::Edges() const
{
return mEdgeCollection.Element();
}

template <typename NodeType>
size_t BofDirGraph<NodeType>::NbEdgeFromNode(const uint32_t _Id_U32) const
{
std::lock_guard<std::mutex> Lock(mMtx);
auto Rts = mEdgeFromNodeCollection.Find(_Id_U32);
BOF_ASSERT(Rts != mEdgeFromNodeCollection.end());
BOF_ASSERT(Rts != mEdgeFromNodeCollection.cend());
return *Rts;
}

Expand Down

0 comments on commit 0905173

Please sign in to comment.