本文整理汇总了C++中STDMIN函数的典型用法代码示例。如果您正苦于以下问题:C++ STDMIN函数的具体用法?C++ STDMIN怎么用?C++ STDMIN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STDMIN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: STDMIN
unsigned long NullStore::CopyTo(BufferedTransformation &target, unsigned long copyMax) const
{
static byte nullBytes[128];
for (unsigned long i=0; i<copyMax; i+=STDMIN(copyMax-i, 128UL))
target.Put(nullBytes, STDMIN(copyMax-i, 128UL));
return copyMax;
}
示例2: xorbuf
byte X917RNG::GenerateByte()
{
if (randbuf_counter==0)
{
// calculate new enciphered timestamp
if (m_deterministicTimeVector)
{
xorbuf(dtbuf, (byte *)&m_deterministicTimeVector, STDMIN((int)sizeof(m_deterministicTimeVector), S));
while (++m_deterministicTimeVector == 0) {} // skip 0
}
else
{
clock_t tstamp = clock();
xorbuf(dtbuf, (byte *)&tstamp, STDMIN((int)sizeof(tstamp), S));
}
cipher->ProcessBlock(dtbuf);
// combine enciphered timestamp with seed
xorbuf(randseed, dtbuf, S);
// generate a new block of random bytes
cipher->ProcessBlock(randseed, randbuf);
// compute new seed vector
for (int i=0; i<S; i++)
randseed[i] = randbuf[i] ^ dtbuf[i];
cipher->ProcessBlock(randseed);
randbuf_counter=S;
}
return(randbuf[--randbuf_counter]);
}
示例3:
unsigned int StringStore::CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end, const std::string &channel, bool blocking) const
{
unsigned int i = (unsigned int)STDMIN((unsigned long)m_count+begin, (unsigned long)m_length);
unsigned int len = (unsigned int)STDMIN((unsigned long)m_length-i, end-begin);
unsigned int blockedBytes = target.ChannelPut2(channel, m_store+i, len, 0, blocking);
if (!blockedBytes)
begin += len;
return blockedBytes;
}
示例4: STDMIN
byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(size_t &numberOfBytes)
{
numberOfBytes = STDMIN(numberOfBytes, STDMIN(size_t(m_buffer.end()-m_begin), m_size));
byte *ptr = m_begin;
m_begin += numberOfBytes;
m_size -= numberOfBytes;
if (m_size == 0 || m_begin == m_buffer.end())
m_begin = m_buffer;
return ptr;
}
示例5: PutDecodedDatumInto
void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransformation &target)
{
std::string s1 = GetRequiredDatum(data, name), s2;
ByteQueue q;
while (!s1.empty())
{
while (s1[0] == ' ')
{
s1 = s1.substr(1);
if (s1.empty())
goto end; // avoid invalid read if s1 is empty
}
int repeat = 1;
if (s1[0] == 'r')
{
repeat = atoi(s1.c_str()+1);
s1 = s1.substr(s1.find(' ')+1);
}
s2 = ""; // MSVC 6 doesn't have clear();
if (s1[0] == '\"')
{
s2 = s1.substr(1, s1.find('\"', 1)-1);
s1 = s1.substr(s2.length() + 2);
}
else if (s1.substr(0, 2) == "0x")
{
StringSource(s1.substr(2, s1.find(' ')), true, new HexDecoder(new StringSink(s2)));
s1 = s1.substr(STDMIN(s1.find(' '), s1.length()));
}
else
{
StringSource(s1.substr(0, s1.find(' ')), true, new HexDecoder(new StringSink(s2)));
s1 = s1.substr(STDMIN(s1.find(' '), s1.length()));
}
while (repeat--)
{
q.Put((const byte *)s2.data(), s2.size());
RandomizedTransfer(q, target, false);
}
}
end:
RandomizedTransfer(q, target, true);
}
示例6: STDMIN
void AdditiveCipherTemplate<S>::GenerateBlock(byte *outString, size_t length)
{
if (m_leftOver > 0)
{
const size_t len = STDMIN(m_leftOver, length);
memcpy(outString, PtrSub(KeystreamBufferEnd(), m_leftOver), len);
length -= len; m_leftOver -= len;
outString = PtrAdd(outString, len);
if (!length) {return;}
}
PolicyInterface &policy = this->AccessPolicy();
unsigned int bytesPerIteration = policy.GetBytesPerIteration();
if (length >= bytesPerIteration)
{
const size_t iterations = length / bytesPerIteration;
policy.WriteKeystream(outString, iterations);
length -= iterations * bytesPerIteration;
outString = PtrAdd(outString, iterations * bytesPerIteration);
}
if (length > 0)
{
size_t bufferByteSize = RoundUpToMultipleOf(length, bytesPerIteration);
size_t bufferIterations = bufferByteSize / bytesPerIteration;
policy.WriteKeystream(PtrSub(KeystreamBufferEnd(), bufferByteSize), bufferIterations);
memcpy(outString, PtrSub(KeystreamBufferEnd(), bufferByteSize), length);
m_leftOver = bufferByteSize - length;
}
}
示例7: STDMIN
unsigned int ByteQueueNode::Get(byte *outString, unsigned int getMax)
{
unsigned int l = STDMIN(getMax, tail-head);
memcpy(outString, buf+head, l);
head += l;
return l;
}
示例8: BadBlockErr
void Inflator::OutputPast(unsigned int length, unsigned int distance)
{
if (distance > m_maxDistance)
throw BadBlockErr();
unsigned int start;
if (m_current > distance)
start = m_current - distance;
else
start = m_current + m_window.size - distance;
if (start + length > m_window.size)
{
for (; start < m_window.size; start++, length--)
OutputByte(m_window[start]);
start = 0;
}
if (start + length > m_current || m_current + length >= m_window.size)
{
while (length--)
OutputByte(m_window[start++]);
}
else
{
memcpy(m_window + m_current, m_window + start, length);
m_current += length;
m_maxDistance = STDMIN(m_window.size, m_maxDistance + length);
}
}
示例9: while
size_t Grouper::Put2(const byte *begin, size_t length, int messageEnd, bool blocking)
{
FILTER_BEGIN;
if (m_groupSize)
{
while (m_inputPosition < length)
{
if (m_counter == m_groupSize)
{
FILTER_OUTPUT(1, m_separator, m_separator.size(), 0);
m_counter = 0;
}
size_t len;
FILTER_OUTPUT2(2, len = STDMIN(length-m_inputPosition, m_groupSize-m_counter),
begin+m_inputPosition, len, 0);
m_inputPosition += len;
m_counter += len;
}
}
else
FILTER_OUTPUT(3, begin, length, 0);
if (messageEnd)
{
FILTER_OUTPUT(4, m_terminator, m_terminator.size(), messageEnd);
m_counter = 0;
}
FILTER_END_NO_MESSAGE_END
}
示例10: CopyTo
unsigned long RandomNumberStore::CopyTo(BufferedTransformation &target, unsigned long copyMax) const
{
unsigned int len = (unsigned int)STDMIN((unsigned long)(m_length-m_count), copyMax);
for (unsigned int i=0; i<len; i++)
target.Put(m_rng.GenerateByte());
return len;
}
示例11: STDMIN
unsigned int MessageQueue::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
{
transferBytes = STDMIN(MaxRetrievable(), transferBytes);
unsigned int blockedBytes = m_queue.TransferTo2(target, transferBytes, channel, blocking);
m_lengths.front() -= transferBytes;
return blockedBytes;
}
示例12: TransferTo
inline unsigned int TransferTo(BufferedTransformation &target, unsigned int transferMax, const std::string &channel=BufferedTransformation::NULL_CHANNEL)
{
unsigned int len = STDMIN(transferMax, m_tail-m_head);
target.ChannelPutModifiable(channel, buf+m_head, len);
m_head += len;
return len;
}
示例13: while
unsigned int Grouper::Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking)
{
if (m_groupSize)
{
FILTER_BEGIN;
while (m_inputPosition < length)
{
if (m_counter == m_groupSize)
{
FILTER_OUTPUT(1, m_seperator, m_seperator.size(), 0);
m_counter = 0;
}
unsigned int len;
FILTER_OUTPUT2(2, len = STDMIN(length-m_inputPosition, m_groupSize-m_counter),
begin+m_inputPosition, len, 0);
m_inputPosition += len;
m_counter += len;
}
if (messageEnd)
FILTER_OUTPUT(3, m_terminator, m_terminator.size(), messageEnd);
FILTER_END_NO_MESSAGE_END
}
else
return Output(0, begin, length, messageEnd, blocking);
示例14: CleanupUsedNodes
unsigned int ByteQueue::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
{
if (blocking)
{
unsigned long bytesLeft = transferBytes;
for (ByteQueueNode *current=m_head; bytesLeft && current; current=current->next)
bytesLeft -= current->TransferTo(target, bytesLeft, channel);
CleanupUsedNodes();
unsigned int len = (unsigned int)STDMIN(bytesLeft, (unsigned long)m_lazyLength);
if (len)
{
target.ChannelPut(channel, m_lazyString, len);
m_lazyString += len;
m_lazyLength -= len;
bytesLeft -= len;
}
transferBytes -= bytesLeft;
return 0;
}
else
{
Walker walker(*this);
unsigned int blockedBytes = walker.TransferTo2(target, transferBytes, channel, blocking);
Skip(transferBytes);
return blockedBytes;
}
}
示例15: CleanupUsedNodes
size_t ByteQueue::TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel, bool blocking)
{
if (blocking)
{
lword bytesLeft = transferBytes;
for (ByteQueueNode *current=m_head; bytesLeft && current; current=current->next)
bytesLeft -= current->TransferTo(target, bytesLeft, channel);
CleanupUsedNodes();
size_t len = (size_t)STDMIN(bytesLeft, (lword)m_lazyLength);
if (len)
{
if (m_lazyStringModifiable)
target.ChannelPutModifiable(channel, m_lazyString, len);
else
target.ChannelPut(channel, m_lazyString, len);
m_lazyString += len;
m_lazyLength -= len;
bytesLeft -= len;
}
transferBytes -= bytesLeft;
return 0;
}
else
{
Walker walker(*this);
size_t blockedBytes = walker.TransferTo2(target, transferBytes, channel, blocking);
Skip(transferBytes);
return blockedBytes;
}
}