Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f24a7b7
commit 15935cc
Showing
15 changed files
with
305 additions
and
92 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,45 @@ | ||
#pragma once | ||
|
||
template<class T> class PersistentVector; | ||
template<class Type> class PersistentVector; | ||
|
||
template<class T> class VectorAccessor { | ||
template<class Type> class VectorAccessor { | ||
friend class PersistentVector<Type>; | ||
friend class VectorIterator<Type>; | ||
|
||
friend class PersistentVector<T>; | ||
PersistentVector<Type> *m_vector; | ||
size_t m_pos; // current iterator position | ||
Type m_value; // current value | ||
|
||
protected: | ||
|
||
PersistentVector<T>& m_pv; | ||
int m_pos; | ||
VectorAccessor(PersistentVector<Type> *vector, size_t pos) | ||
: m_vector(vector) | ||
, m_pos(pos) | ||
{} | ||
|
||
public: | ||
|
||
VectorAccessor(PersistentVector<T>& pv, int index) : m_pv(pv), m_pos(index) {} | ||
|
||
PersistentVector<T>& operator=(int val) { | ||
m_pv.write(m_pos, val); | ||
return m_pv; | ||
typedef const Type& const_reference; | ||
|
||
VectorAccessor(const VectorAccessor& vh) | ||
: m_vector(0) | ||
, m_pos(-1) | ||
, m_value(vh) | ||
{} | ||
|
||
VectorAccessor& operator=(const_reference val) { | ||
if (m_vector) | ||
m_vector->write(m_pos, val); | ||
else | ||
m_value = val; | ||
return *this; | ||
} | ||
|
||
operator VectorIterator<T> const& () { | ||
return VectorIterator<T> a(m_pv ,m_pos); | ||
} | ||
operator PersistentVector<T> const& () { | ||
return m_pv; | ||
} | ||
operator T const () { | ||
return m_pv.read(m_pos); | ||
VectorAccessor& operator=(const VectorAccessor& vh) { | ||
if (m_vector) | ||
m_vector->write(m_pos, vh); | ||
else | ||
m_value = vh; | ||
return *this; | ||
} | ||
|
||
}; | ||
operator Type() const { return (m_vector) ? m_vector->read(m_pos) : m_value; } | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
template<class T> class PersistentVector; | ||
|
||
template<class T> class VectorAccessor { | ||
|
||
friend class PersistentVector<T>; | ||
|
||
protected: | ||
|
||
PersistentVector<T>& m_pv; | ||
int m_pos; | ||
|
||
public: | ||
|
||
VectorAccessor(PersistentVector<T>& pv, int index) : m_pv(pv), m_pos(index) {} | ||
|
||
PersistentVector<T>& operator=(T val) { | ||
m_pv.write(m_pos, val); | ||
return m_pv; | ||
} | ||
|
||
operator PersistentVector<T> const& () { | ||
return m_pv; | ||
} | ||
operator T const () { | ||
return m_pv.read(m_pos); | ||
} | ||
|
||
}; |
Oops, something went wrong.