本文整理汇总了C++中libmaus2::autoarray::AutoArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoArray::begin方法的具体用法?C++ AutoArray::begin怎么用?C++ AutoArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libmaus2::autoarray::AutoArray
的用法示例。
在下文中一共展示了AutoArray::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
static libmaus2::autoarray::AutoArray<char> loadFile(std::istream & in)
{
libmaus2::autoarray::AutoArray<char> C(1);
uint64_t p = 0;
while ( in )
{
in.read(C.begin() + p, C.size()-p);
if ( ! in.gcount() )
break;
p += in.gcount();
if ( p == C.size() )
{
libmaus2::autoarray::AutoArray<char> Cn(2*C.size(),false);
std::copy(C.begin(),C.end(),Cn.begin());
C = Cn;
}
}
libmaus2::autoarray::AutoArray<char> Cn(p,false);
std::copy(C.begin(),C.begin()+p,Cn.begin());
return Cn;
}
示例2: underflow
int_type underflow()
{
if ( gptr() < egptr() )
return static_cast<int_type>(*uptr());
assert ( gptr() == egptr() );
char * midptr = buffer.begin() + pushbackspace;
uint64_t const copyavail =
std::min(
// previously read
static_cast<uint64_t>(gptr()-eback()),
// space we have to copy into
static_cast<uint64_t>(midptr-buffer.begin())
);
::std::memmove(midptr-copyavail,gptr()-copyavail,copyavail);
stream.read(midptr, buffer.end()-midptr);
size_t const n = stream.gcount();
streamreadpos += n;
setg(midptr-copyavail, midptr, midptr+n);
if (!n)
return traits_type::eof();
return static_cast<int_type>(*uptr());
}
示例3: decodeBlock
bool decodeBlock()
{
while ( FBO.file < index.Vfn.size() && FBO.block >= index.blocksPerFile[FBO.file] )
{
FBO.file++;
FBO.block = 0;
FBO.blockoffset = 0; // check this if we change the file format
FBO.offset = 0;
openFile();
}
if ( FBO.file == index.Vfn.size() )
{
PSGI.reset();
PISI.reset();
return false;
}
libmaus2::gamma::GammaDecoder< libmaus2::aio::SynchronousGenericInput<uint64_t> > GD(*PSGI);
uint64_t const bs = GD.decode() + 1;
B.ensureSize(bs);
for ( uint64_t i = 0; i < bs; ++i )
B[i] = GD.decode();
pa = B.begin();
pc = B.begin();
pe = B.begin() + bs;
FBO.block += 1;
return true;
}
示例4: fillBuffer
void fillBuffer()
{
assert ( pc == pe );
if ( setpos )
{
// std::cerr << "Seeking to " << readpos << std::endl;
in.seekg(readpos);
in.clear();
}
if ( in.peek() >= 0 && readpos < endpos )
{
#if 0
std::cerr << "Filling block, readpos " << readpos
<< " stream at pos " << in.tellg()
<< " endpos " << endpos
<< std::endl;
#endif
uint64_t blocksize = sizeof(uint64_t) + sizeof(uint64_t);
// size of uncompressed buffer
uint64_t const n = ::libmaus2::util::NumberSerialisation::deserialiseNumber(in);
// size of compressed data
uint64_t const datasize = ::libmaus2::util::NumberSerialisation::deserialiseNumber(in);
// add to block size
blocksize += datasize;
if ( n > B.size() )
{
B = ::libmaus2::autoarray::AutoArray<char>(0,false);
B = ::libmaus2::autoarray::AutoArray<char>(n,false);
}
pa = B.begin();
pc = pa;
pe = pa + n;
::libmaus2::aio::IStreamWrapper wrapper(in);
::libmaus2::lz::IstreamSource< ::libmaus2::aio::IStreamWrapper> insource(wrapper,datasize);
try
{
SnappyCompress::uncompress(insource,B.begin(),n);
}
catch(std::exception const & ex)
{
libmaus2::exception::LibMausException lme;
lme.getStream() << "Failed to decompress snappy compressed data, comp=" << datasize << ", uncomp=" << n << ":\n" << ex.what() << "\n";
lme.finish();
throw lme;
}
readpos += blocksize;
}
}
示例5: underflow
int_type underflow()
{
if ( gptr() < egptr() )
return static_cast<int_type>(*uptr());
assert ( gptr() == egptr() );
char * midptr = buffer.begin() + pushbackspace;
uint64_t const copyavail =
std::min(
// previously read
static_cast<uint64_t>(gptr()-eback()),
// space we have to copy into
static_cast<uint64_t>(midptr-buffer.begin())
);
::std::memmove(midptr-copyavail,gptr()-copyavail,copyavail);
size_t n = 0;
bool done = false;
while ( ! done )
{
BgzfInflateInfo const info = stream.readAndInfo(midptr, buffer.end()-midptr);
n = info.uncompressed;
// non eof block
if ( n )
{
streamreadpos += n;
done = true;
}
else
{
// eof block at end of stream
if ( info.streameof )
{
done = true;
}
// intermediate empty block, skip it
else
{
}
}
}
setg(midptr-copyavail, midptr, midptr+n);
if (!n)
return traits_type::eof();
return static_cast<int_type>(*uptr());
}
示例6: nm
MdStringComputationContext()
: T0(256,false), T1(256,false), nm(0)
{
std::fill(T0.begin(),T0.end(),4);
std::fill(T1.begin(),T1.end(),5);
T0['A'] = T0['a'] = T1['A'] = T1['a'] = 0;
T0['C'] = T0['c'] = T1['C'] = T1['c'] = 1;
T0['G'] = T0['g'] = T1['G'] = T1['g'] = 2;
T0['T'] = T0['t'] = T1['T'] = T1['t'] = 3;
auxvec.set("MD");
auxvec.set("NM");
}
示例7: Pstream
ExternalMemoryIndexGenerator(std::string const & filename)
: Pstream(libmaus2::aio::InputOutputStreamFactoryContainer::constructUnique(filename,std::ios::in|std::ios::out|std::ios::trunc|std::ios::binary)), stream(*Pstream),
ic(0), flushed(false), writeCache(1024),
wa(writeCache.begin()), wc(wa), we(writeCache.end())
{
}
示例8: get
void get(uint64_t const i, libmaus2::bambam::GeneFlatFileEntry & entry) const
{
if ( i >= nl )
{
libmaus2::exception::LibMausException lme;
lme.getStream() << "GeneFlatFile::get(): line " << i << " is out of range." << std::endl;
lme.finish();
throw lme;
}
std::pair<uint64_t,uint64_t> P = LA->lineInterval(i);
while ( P.second != P.first && isspace(C[P.second-1]) )
--P.second;
entry.reset(C.begin() + P.first,C.begin() + P.second);
}
示例9: writer
RLEncoderBaseTemplate(bit_writer_type & rwriter, uint64_t const rnumsyms, uint64_t const bufsize = 4ull*1024ull*1024ull)
: writer(rwriter), numsyms(rnumsyms), rlbuffer(bufsize), pa(rlbuffer.begin()), pc(pa), pe(rlbuffer.end()), cursym(0), curcnt(0),
indexwritten(false)
{
// std::cerr << "Writing RL file of length " << numsyms << std::endl;
writer.writeElias2(numsyms);
}
示例10: UNIQUE_PTR_MOVE
::libmaus2::util::Histogram::unique_ptr_type libmaus2::util::Utf8String::getHistogram(::libmaus2::autoarray::AutoArray<uint8_t> const & A)
{
#if defined(_OPENMP)
uint64_t const numthreads = omp_get_max_threads();
#else
uint64_t const numthreads = 1;
#endif
::libmaus2::autoarray::AutoArray<uint64_t> const partstarts = computePartStarts(A,numthreads);
uint64_t const numparts = partstarts.size()-1;
::libmaus2::util::Histogram::unique_ptr_type hist(new ::libmaus2::util::Histogram);
::libmaus2::parallel::OMPLock lock;
#if defined(_OPENMP)
#pragma omp parallel for
#endif
for ( int64_t t = 0; t < static_cast<int64_t>(numparts); ++t )
{
::libmaus2::util::Histogram::unique_ptr_type lhist(new ::libmaus2::util::Histogram);
uint64_t codelen = 0;
uint64_t const tcodelen = partstarts[t+1]-partstarts[t];
::libmaus2::util::GetObject<uint8_t const *> G(A.begin()+partstarts[t]);
while ( codelen != tcodelen )
(*lhist)(::libmaus2::util::UTF8::decodeUTF8(G,codelen));
lock.lock();
hist->merge(*lhist);
lock.unlock();
}
return UNIQUE_PTR_MOVE(hist);
}
示例11: underflow
int_type underflow()
{
// if there is still data, then return it
if ( gptr() < egptr() )
return static_cast<int_type>(*(reinterpret_cast<uint8_t const *>(gptr())));
assert ( gptr() == egptr() );
// number of bytes for putback buffer
uint64_t const putbackcopy = std::min(
static_cast<uint64_t>(gptr() - eback()),
putbackspace
);
// copy bytes
#if 0
std::copy(
gptr()-putbackcopy,
gptr(),
buffer.begin() + putbackspace - putbackcopy
);
#endif
std::memmove(
buffer.begin() + putbackspace - putbackcopy,
gptr()-putbackcopy,
putbackcopy
);
// load data
uint64_t const uncompressedsize = stream.readPart(
buffer.begin()+putbackspace,
buffer.size()-putbackspace
);
// set buffer pointers
setg(
buffer.begin()+putbackspace-putbackcopy,
buffer.begin()+putbackspace,
buffer.begin()+putbackspace+uncompressedsize
);
if ( uncompressedsize )
return static_cast<int_type>(*(reinterpret_cast<uint8_t const *>(gptr())));
else
return traits_type::eof();
}
示例12: fd
LinuxStreamingPosixFdOutputStreamBuffer(std::string const & fn, int64_t const rbuffersize)
: fd(doOpen(fn)), closefd(true),
optblocksize((rbuffersize < 0) ? getOptimalIOBlockSize(fd,std::string()) : rbuffersize),
buffersize(optblocksize),
buffer(buffersize,false), prevwrite(0,0)
{
setp(buffer.begin(),buffer.end()-1);
}
示例13: fd
MemoryOutputStreamBuffer(std::string const & fn, int64_t const rbuffersize)
:
fd(doOpen(fn)),
buffersize((rbuffersize < 0) ? getDefaultBlockSize() : rbuffersize),
buffer(buffersize,false)
{
setp(buffer.begin(),buffer.end()-1);
}
示例14: B
BgzfParallelRecodeDeflateBase()
: B(getBgzfMaxBlockSize(),false),
pa(B.begin()),
pc(B.begin()),
pe(B.end())
{
}
示例15: underflow
/**
* buffer underflow callback
* @return next symbol
**/
typename base_type::int_type underflow()
{
if ( base_type::gptr() < base_type::egptr() )
return static_cast<typename base_type::int_type>(*uptr());
assert ( base_type::gptr() == base_type::egptr() );
char_type * midptr = buffer.begin() + pushbackspace;
uint64_t const copyavail =
std::min(
// previously read
static_cast<uint64_t>(base_type::gptr()-base_type::eback()),
// space we have to copy into
static_cast<uint64_t>(midptr-buffer.begin())
);
::std::memmove(midptr-copyavail,base_type::gptr()-copyavail,copyavail*sizeof(char_type));
if ( static_cast<int64_t>(stream.tellg()) == static_cast<int64_t>(0) )
{
stream.seekg(infilesize);
stream.clear();
}
uint64_t const rspace = stream.tellg();
uint64_t const toread = std::min(rspace,static_cast<uint64_t>(buffer.end()-midptr));
stream.seekg(-static_cast<int64_t>(toread),std::ios::cur);
stream.clear();
stream.read(midptr, toread);
size_t const n = stream.gcount();
assert ( n == toread );
std::reverse(midptr,midptr+n);
streamreadpos += n;
stream.seekg(-static_cast<int64_t>(toread),std::ios::cur);
stream.clear();
base_type::setg(midptr-copyavail, midptr, midptr+n);
if (!n)
return base_type::traits_type::eof();
return static_cast<typename base_type::int_type>(*uptr());
}