Skip to content

Commit

Permalink
FileItemGenerator(,skipHeader)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrover committed Oct 21, 2021
1 parent d0f628a commit 11ce6e5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
19 changes: 15 additions & 4 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2831,14 +2831,17 @@ size_t Offset::size = 0;
FileItemGenerator::FileItemGenerator (size_t progress_displayPeriod,
bool isDir_arg,
bool large_arg,
const string& fName_arg)
const string& fName_arg,
bool skipHeader_arg)
: ItemGenerator (0, progress_displayPeriod)
, isDir (isDir_arg)
, large (large_arg)
, dirName (fName_arg)
, fName (fName_arg)
, skipHeader (skipHeader_arg)
{
IMPLY (large, isDir);
QC_IMPLY (large, isDir);
QC_IMPLY (skipHeader, ! isDir);

trimSuffix (dirName, "/");

Expand Down Expand Up @@ -2879,7 +2882,14 @@ FileItemGenerator::FileItemGenerator (size_t progress_displayPeriod,
bool FileItemGenerator::next (string &item)
{
if (! large)
{
if (skipHeader)
{
next_ (item);
skipHeader = false;
}
return next_ (item);
}

for (;;)
{
Expand All @@ -2888,7 +2898,7 @@ bool FileItemGenerator::next (string &item)
string subDir;
if (! next_ (subDir))
return false;
fig. reset (new FileItemGenerator (0, true, false, dirName + "/" + subDir));
fig. reset (new FileItemGenerator (0, true, false, dirName + "/" + subDir, false));
}
ASSERT (fig. get ());
if (fig->next (item))
Expand Down Expand Up @@ -2918,7 +2928,8 @@ bool FileItemGenerator::next_ (string &item)
if (item. empty () && f. eof ())
return false;

prog (item);
if (! skipHeader)
prog (item);
return true;
}

Expand Down
8 changes: 5 additions & 3 deletions common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ template <typename Key, typename Value>
}

template <typename T, typename UnaryPredicate>
inline long count_if (T &t, UnaryPredicate pred)
{ return std::count_if (t. begin (), t. end (), pred); }
inline size_t count_if (T &t, UnaryPredicate pred)
{ return (size_t) std::count_if (t. begin (), t. end (), pred); }

template <typename To, typename From>
inline void insertAll (To &to,
Expand Down Expand Up @@ -3758,13 +3758,15 @@ struct FileItemGenerator : ItemGenerator, Nocopy
string fName;
ifstream f;
unique_ptr<FileItemGenerator> fig;
bool skipHeader {false};
public:


FileItemGenerator (size_t progress_displayPeriod,
bool isDir_arg,
bool large_arg,
const string& fName_arg);
const string& fName_arg,
bool skipHeader_arg);
~FileItemGenerator ()
{ if (isDir)
remove (fName. c_str ());
Expand Down
2 changes: 1 addition & 1 deletion phylogeny/distTree_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Update: <incremental distance tree directory>/search/")
if (name. empty ())
{
const string newDir (dataDir + "search/");
FileItemGenerator fig (1, true, false, newDir); // PAR
FileItemGenerator fig (1, true, false, newDir, false); // PAR
string item;
while (fig. next (item))
{
Expand Down
2 changes: 1 addition & 1 deletion phylogeny/mutation2feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct ThisApplication : Application
map<string/*Mutation::geneName*/,unordered_set<Mutation,Mutation::Hash>> gene2muts;
// !Mutation::ambig
{
FileItemGenerator fig (1000, true, large, inDirName); // PAR
FileItemGenerator fig (1000, true, large, inDirName, false); // PAR
string fName;
while (fig. next (fName))
{
Expand Down
3 changes: 2 additions & 1 deletion version.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define VERSION "1.9.5"
#define VERSION "1.9.6"


// 1.9.6 10/18/2021 distTree_inc_refresh_dissim.sh
// 1.9.5 07/23/2021 -prefer_gain is restored in tree2names.sh
// 1.9.4 06/09/2021 combine_dissims.cpp: -barrier
// 1.9.3 05/30/2021 align.cpp: ambiguous aa J,U,O are replaced by X, selfScore is using X
Expand Down

0 comments on commit 11ce6e5

Please sign in to comment.