mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Better way to construct SetListingView
This commit is contained in:
parent
2a7b8437ed
commit
bed191c4fc
3 changed files with 32 additions and 27 deletions
|
@ -54,33 +54,14 @@ namespace mchlib {
|
|||
};
|
||||
};
|
||||
|
||||
class SetListing {
|
||||
friend class SetListingView;
|
||||
public:
|
||||
typedef std::vector<FileRecordData> ListType;
|
||||
typedef implem::DirIterator const_iterator;
|
||||
|
||||
explicit SetListing ( ListType&& parList, bool parSort=true );
|
||||
~SetListing ( void ) noexcept;
|
||||
|
||||
const_iterator begin ( void ) const;
|
||||
const_iterator cbegin ( void ) const;
|
||||
const_iterator end ( void ) const;
|
||||
const_iterator cend ( void ) const;
|
||||
|
||||
//ListType descend_copy ( const const_iterator& parItem ) const;
|
||||
|
||||
private:
|
||||
ListType m_list;
|
||||
};
|
||||
|
||||
class SetListingView {
|
||||
public:
|
||||
typedef SetListing::const_iterator const_iterator;
|
||||
typedef SetListing::ListType::const_iterator list_iterator;
|
||||
typedef implem::DirIterator const_iterator;
|
||||
typedef std::vector<FileRecordData>::const_iterator list_iterator;
|
||||
|
||||
explicit SetListingView ( const const_iterator& parIter );
|
||||
explicit SetListingView ( const SetListing& parListing );
|
||||
SetListingView ( list_iterator parBeg, list_iterator parEnd );
|
||||
SetListingView ( SetListingView&& ) = default;
|
||||
~SetListingView ( void ) noexcept = default;
|
||||
|
||||
const_iterator begin ( void ) const;
|
||||
|
@ -92,6 +73,26 @@ namespace mchlib {
|
|||
list_iterator m_begin;
|
||||
list_iterator m_end;
|
||||
};
|
||||
|
||||
class SetListing {
|
||||
public:
|
||||
typedef std::vector<FileRecordData> ListType;
|
||||
typedef SetListingView::const_iterator const_iterator;
|
||||
|
||||
explicit SetListing ( ListType&& parList, bool parSort=true );
|
||||
~SetListing ( void ) noexcept;
|
||||
|
||||
const_iterator begin ( void ) const;
|
||||
const_iterator cbegin ( void ) const;
|
||||
const_iterator end ( void ) const;
|
||||
const_iterator cend ( void ) const;
|
||||
|
||||
//ListType descend_copy ( const const_iterator& parItem ) const;
|
||||
SetListingView make_view ( void ) const;
|
||||
|
||||
private:
|
||||
ListType m_list;
|
||||
};
|
||||
} //namespace mchlib
|
||||
|
||||
#endif
|
||||
|
|
|
@ -145,15 +145,19 @@ namespace mchlib {
|
|||
return const_iterator(m_list.end(), m_list.end(), std::unique_ptr<PathName>());
|
||||
}
|
||||
|
||||
SetListingView SetListing::make_view() const {
|
||||
return SetListingView(m_list.begin(), m_list.end());
|
||||
}
|
||||
|
||||
SetListingView::SetListingView (const const_iterator& parIter) :
|
||||
m_begin(parIter.m_current),
|
||||
m_end(parIter.m_end)
|
||||
{
|
||||
}
|
||||
|
||||
SetListingView::SetListingView (const SetListing& parListing) :
|
||||
m_begin(parListing.m_list.begin()),
|
||||
m_end(parListing.m_list.end())
|
||||
SetListingView::SetListingView (list_iterator parBeg, list_iterator parEnd) :
|
||||
m_begin(parBeg),
|
||||
m_end(parEnd)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ TEST(machinery, diriterator) {
|
|||
|
||||
std::vector<std::string> flattened;
|
||||
flattened.reserve(lengthof(expected_list));
|
||||
flatten_filelist(SetListingView(lst), flattened);
|
||||
flatten_filelist(lst.make_view(), flattened);
|
||||
EXPECT_EQ(lengthof(expected_list), flattened.size());
|
||||
const auto count = std::min(lengthof(expected_list), flattened.size());
|
||||
for (std::size_t z = 0; z < count; ++z) {
|
||||
|
|
Loading…
Reference in a new issue