mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Remove vector iterator type aliases from SmithWaterman code, fix uses of them
This commit is contained in:
parent
9f802b2a4d
commit
6d9d66b8ce
2 changed files with 28 additions and 43 deletions
|
@ -16,8 +16,8 @@ namespace zeek::detail {
|
||||||
Substring::Substring(const Substring& bst)
|
Substring::Substring(const Substring& bst)
|
||||||
: zeek::String((const zeek::String&) bst), _num(), _new(bst._new)
|
: zeek::String((const zeek::String&) bst), _num(), _new(bst._new)
|
||||||
{
|
{
|
||||||
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it )
|
for ( const auto& align : bst._aligns )
|
||||||
_aligns.push_back(*it);
|
_aligns.push_back(align);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Substring& Substring::operator=(const Substring& bst)
|
const Substring& Substring::operator=(const Substring& bst)
|
||||||
|
@ -26,8 +26,8 @@ const Substring& Substring::operator=(const Substring& bst)
|
||||||
|
|
||||||
_aligns.clear();
|
_aligns.clear();
|
||||||
|
|
||||||
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it )
|
for ( const auto& align : bst._aligns )
|
||||||
_aligns.push_back(*it);
|
_aligns.push_back(align);
|
||||||
|
|
||||||
_new = bst._new;
|
_new = bst._new;
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ bool Substring::DoesCover(const Substring* bst) const
|
||||||
if ( _aligns.size() != bst->_aligns.size() )
|
if ( _aligns.size() != bst->_aligns.size() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BSSAlignVecCIt it_bst = bst->_aligns.begin();
|
auto it_bst = bst->_aligns.begin();
|
||||||
|
|
||||||
for ( BSSAlignVecCIt it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst )
|
for ( auto it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst )
|
||||||
{
|
{
|
||||||
const BSSAlign& a = *it;
|
const BSSAlign& a = *it;
|
||||||
const BSSAlign& a_bst = *it_bst;
|
const BSSAlign& a_bst = *it_bst;
|
||||||
|
@ -134,9 +134,9 @@ char* Substring::VecToString(Vec* vec)
|
||||||
{
|
{
|
||||||
std::string result("[");
|
std::string result("[");
|
||||||
|
|
||||||
for ( Substring::VecIt it = vec->begin(); it != vec->end(); ++it )
|
for ( const auto& ss : *vec )
|
||||||
{
|
{
|
||||||
result += (*it)->CheckString();
|
result += ss->CheckString();
|
||||||
result += ",";
|
result += ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,17 +148,14 @@ zeek::String::IdxVec* Substring::GetOffsetsVec(const Vec* vec, unsigned int inde
|
||||||
{
|
{
|
||||||
zeek::String::IdxVec* result = new zeek::String::IdxVec();
|
zeek::String::IdxVec* result = new zeek::String::IdxVec();
|
||||||
|
|
||||||
for ( VecCIt it = vec->begin(); it != vec->end(); ++it )
|
for ( const auto& bst : *vec )
|
||||||
{
|
{
|
||||||
int start, end;
|
|
||||||
const Substring* bst = (*it);
|
|
||||||
|
|
||||||
if ( bst->_aligns.size() <= index )
|
if ( bst->_aligns.size() <= index )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const BSSAlign& align = bst->_aligns[index];
|
const BSSAlign& align = bst->_aligns[index];
|
||||||
start = align.index;
|
int start = align.index;
|
||||||
end = start + bst->Len();
|
int end = start + bst->Len();
|
||||||
|
|
||||||
result->push_back(start);
|
result->push_back(start);
|
||||||
result->push_back(end);
|
result->push_back(end);
|
||||||
|
@ -327,7 +324,7 @@ static void sw_collect_single(Substring::Vec* result, SWNodeMatrix& matrix,
|
||||||
// substrings are redundant (i.e., fully covered by a larger common substring).
|
// substrings are redundant (i.e., fully covered by a larger common substring).
|
||||||
//
|
//
|
||||||
static void sw_collect_multiple(Substring::Vec* result,
|
static void sw_collect_multiple(Substring::Vec* result,
|
||||||
SWNodeMatrix& matrix, SWParams& params)
|
SWNodeMatrix& matrix, SWParams& params)
|
||||||
{
|
{
|
||||||
std::vector<Substring::Vec*> als;
|
std::vector<Substring::Vec*> als;
|
||||||
|
|
||||||
|
@ -343,21 +340,16 @@ static void sw_collect_multiple(Substring::Vec* result,
|
||||||
auto* new_al = new Substring::Vec();
|
auto* new_al = new Substring::Vec();
|
||||||
sw_collect_single(new_al, matrix, node, params);
|
sw_collect_single(new_al, matrix, node, params);
|
||||||
|
|
||||||
for ( std::vector<Substring::Vec*>::iterator it = als.begin();
|
for ( auto& old_al : als )
|
||||||
it != als.end(); ++it )
|
|
||||||
{
|
{
|
||||||
Substring::Vec* old_al = *it;
|
|
||||||
|
|
||||||
if ( old_al == nullptr )
|
if ( old_al == nullptr )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for ( Substring::VecIt it2 = old_al->begin();
|
for ( const auto& old_ss : *old_al )
|
||||||
it2 != old_al->end(); ++it2 )
|
|
||||||
{
|
{
|
||||||
for ( Substring::VecIt it3 = new_al->begin();
|
for ( const auto& new_ss : *new_al )
|
||||||
it3 != new_al->end(); ++it3 )
|
|
||||||
{
|
{
|
||||||
if ( (*it2)->DoesCover(*it3) )
|
if ( old_ss->DoesCover(new_ss) )
|
||||||
{
|
{
|
||||||
zeek::util::delete_each(new_al);
|
zeek::util::delete_each(new_al);
|
||||||
delete new_al;
|
delete new_al;
|
||||||
|
@ -365,11 +357,11 @@ static void sw_collect_multiple(Substring::Vec* result,
|
||||||
goto end_loop;
|
goto end_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (*it3)->DoesCover(*it2) )
|
if ( new_ss->DoesCover(old_ss) )
|
||||||
{
|
{
|
||||||
zeek::util::delete_each(old_al);
|
zeek::util::delete_each(old_al);
|
||||||
delete old_al;
|
delete old_al;
|
||||||
*it = 0;
|
old_al = nullptr;
|
||||||
goto end_loop;
|
goto end_loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,17 +374,13 @@ end_loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( std::vector<Substring::Vec*>::iterator it = als.begin();
|
for ( const auto& al : als )
|
||||||
it != als.end(); ++it )
|
|
||||||
{
|
{
|
||||||
Substring::Vec* al = *it;
|
|
||||||
|
|
||||||
if ( al == nullptr )
|
if ( al == nullptr )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for ( Substring::VecIt it2 = al->begin();
|
for ( const auto& bst : *al )
|
||||||
it2 != al->end(); ++it2 )
|
result->push_back(bst);
|
||||||
result->push_back(*it2);
|
|
||||||
|
|
||||||
delete al;
|
delete al;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ZeekString.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ZeekString.h"
|
||||||
|
|
||||||
namespace zeek::detail {
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
@ -16,9 +18,7 @@ namespace zeek::detail {
|
||||||
class Substring : public zeek::String {
|
class Substring : public zeek::String {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::vector<Substring*> Vec;
|
using Vec = std::vector<Substring*>;
|
||||||
typedef Vec::iterator VecIt;
|
|
||||||
typedef Vec::const_iterator VecCIt;
|
|
||||||
|
|
||||||
// An alignment to another string.
|
// An alignment to another string.
|
||||||
//
|
//
|
||||||
|
@ -37,9 +37,7 @@ public:
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<BSSAlign> BSSAlignVec;
|
using BSSAlignVec = std::vector<BSSAlign>;
|
||||||
typedef BSSAlignVec::iterator BSSAlignVecIt;
|
|
||||||
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
|
|
||||||
|
|
||||||
explicit Substring(const std::string& string)
|
explicit Substring(const std::string& string)
|
||||||
: zeek::String(string), _num(), _new(false) { }
|
: zeek::String(string), _num(), _new(false) { }
|
||||||
|
@ -74,11 +72,10 @@ public:
|
||||||
static Vec* VecFromPolicy(zeek::VectorVal* vec);
|
static Vec* VecFromPolicy(zeek::VectorVal* vec);
|
||||||
static char* VecToString(Vec* vec);
|
static char* VecToString(Vec* vec);
|
||||||
static zeek::String::IdxVec* GetOffsetsVec(const Vec* vec,
|
static zeek::String::IdxVec* GetOffsetsVec(const Vec* vec,
|
||||||
unsigned int index);
|
unsigned int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<std::string, void*> DataMap;
|
using DataMap = std::map<std::string, void*>;
|
||||||
typedef DataMap::iterator DataMapIt;
|
|
||||||
|
|
||||||
Substring();
|
Substring();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue