本文整理汇总了C++中Rewind函数的典型用法代码示例。如果您正苦于以下问题:C++ Rewind函数的具体用法?C++ Rewind怎么用?C++ Rewind使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Rewind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: puts
//DFS with heuristic
void DFSBoard::DoDFS(){
//TODO: choose an answer of the line with minimum possible answer() -> use heuristic to fill board -> check other lineis legal or not -> if legal, next line
puts("doDFS");
vector<int> rowOrder(r);
int nowr = 0;
rowOrder[nowr] = getRowWithMinBranch(nowr, rowOrder);
while(nowr <= r){
puts("nowroworder");
for(int i = 0; i <= nowr; i++)
printf("%d ", rowOrder[i]);
puts("");
if(isAllSolved())
return;
if(!tryFillRowHeuristic(rowOrder[nowr])){//try all possibilities to fill the row, will filling next answer after previous called
if(nowr == 0){
puts("rewind to the first row: no solution:");
break;
}
//all possibilities in row nowr are failed, recover board to previous row(nowr-1)
lastfillStart[rowOrder[nowr]].clear();
Rewind(rowOrder[--nowr]);
} else {// fill answer success, continue filling next row
rowOrder[++nowr] = getRowWithMinBranch(nowr, rowOrder);
if(nowr == r)//complete, check column again
if(isDFSAnswerCorrect())
return;
else
Rewind(rowOrder[--nowr]);
}
}
}
示例2: SaveString
bool EMMediaTransitionTrackRepository::SaveData(EMProjectDataSaver* p_opSaver)
{
p_opSaver -> SaveString("EMMediaTransitionTrackRepository - Begin");
LockContainer();
uint32 vCount = 0;
Rewind();
while(Current() != NULL)
{
if(! Current() -> IsObjectDeleted())
vCount++;
Next();
}
p_opSaver -> SaveUInt32(vCount);
Rewind();
while(Current() != NULL)
{
if(! Current() -> IsObjectDeleted())
Current() -> SaveData(p_opSaver);
Next();
}
UnlockContainer();
p_opSaver -> SaveString("EMMediaTransitionTrackRepository - End");
return true;
}
示例3: AvgByCount
int
AvgByCount(double ts,
double input_val,
void *state_set,
int tau,
double *out_ts,
double *out_val)
{
int ierr;
double curr_ts;
double curr_val;
double count;
double acc;
int size;
int read;
Rewind(state_set);
size = SizeOf(state_set);
acc = input_val;
*out_ts = ts;
count = 1.0;
read = 0;
while((ReadEntry(state_set,&curr_ts,&curr_val) != 0) &&
(count < tau))
{
read += 1;
/*
* -1 because input_val counts
*/
if((size - read) < (tau-1))
{
acc += curr_val;
/*
printf("%f ",curr_val);
*/
count += 1;
}
}
/*
printf("%f ",input_val);
printf(" | ");
*/
*out_val = acc / count;
Rewind(state_set);
return(1);
}
示例4: Rewind
void SDTSPolygonReader::AssembleRings( SDTSTransfer * poTransfer,
int iPolyLayer )
{
if( bRingsAssembled )
return;
bRingsAssembled = TRUE;
/* -------------------------------------------------------------------- */
/* To write polygons we need to build them from their related */
/* arcs. We don't know off hand which arc (line) layers */
/* contribute so we process all line layers, attaching them to */
/* polygons as appropriate. */
/* -------------------------------------------------------------------- */
for( int iLineLayer = 0;
iLineLayer < poTransfer->GetLayerCount();
iLineLayer++ )
{
if( poTransfer->GetLayerType(iLineLayer) != SLTLine )
continue;
SDTSLineReader *poLineReader = reinterpret_cast<SDTSLineReader *>(
poTransfer->GetLayerIndexedReader( iLineLayer ) );
if( poLineReader == nullptr )
continue;
poLineReader->AttachToPolygons( poTransfer, iPolyLayer );
poLineReader->Rewind();
}
if( !IsIndexed() )
return;
/* -------------------------------------------------------------------- */
/* Scan all polygons indexed on this reader, and assemble their */
/* rings. */
/* -------------------------------------------------------------------- */
Rewind();
SDTSFeature *poFeature = nullptr;
while( (poFeature = GetNextFeature()) != nullptr )
{
SDTSRawPolygon *poPoly
= reinterpret_cast<SDTSRawPolygon *>( poFeature );
poPoly->AssembleRings();
}
Rewind();
}
示例5: exit
void logger::OpenFile(string const& path)
{
filePath = path;
//检查文件是否存在
fstream file;
file.open(path + SUFFIX_LOG, ios::in | ios::out | ios::binary);
if (!file)
{
cerr << "No file!" << endl;
exit(EXIT_FAILURE);
}
//检查文件大小是否正确
int begin = file.tellg();
file.seekg(0, ios::end);
int end = file.tellg();
if ((end - begin) < 4)
{
cerr << "Size error!" << endl;
exit(EXIT_FAILURE);
}
//初始化logger类中的fileSize和xChecksum
fileSize = end - begin;
file.seekp(0, ios::beg);
file.read((char*)(&xChecksum), 4);//读取文件中存储的xChecksum
file.close();
//对log文件大小进行核查
Rewind();
uint32_t xChecksum_tmp = checkLogFile();
Rewind();
//文件大小与xChecksum记录的大小不一致,删除文件
if (xChecksum != xChecksum_tmp)
{
cerr << "xChecksum error!" << endl << "Bad log file!" << endl;
//是否Truncate? 是的,Truncate!
// TODO
//由于更新xCheckSum的时候数据库发生崩溃, 则会导致整个log文件不能使用.
//所以暂时放弃xCheckSum, 之后将xCheckSum改为由booter管理.
fstream file(path + SUFFIX_LOG, ios::trunc);
if (file.is_open())
{
file.close();
}
exit(EXIT_FAILURE);
}
}
示例6: CopyDataSet
int CopyDataSet(void *s, void *d, int count)
{
DataSet *src = (DataSet *)s;
DataSet *dst = (DataSet *)d;
int i;
int j;
if(count > SizeOf(src))
{
return(0);
}
if(src->fields != dst->fields)
{
return(0);
}
while(SizeOf(dst) < count)
{
ExpandData((void *)dst);
}
for(i=0; i < count; i++)
{
for(j=0; j < src->fields; j++)
{
dst->data[j][i] = src->data[j][i];
}
}
dst->data_c = count;
Rewind(dst);
return(1);
}
示例7: Rewind
xyMultimap_t baseXYData::GetAccumulation(bool inProcents )
{
double x,y,n=0;
xyMultimap_t map;
std::map<double, int> tmp;
std::map<double, int>::iterator it;
// loop all values
// increment tmp[y] by one when occur
Rewind();
while( GetNextXY(x, y) )
{
if(tmp.find(y)==tmp.end())tmp[y]=1;
else tmp[y]++;
n++;
}
// insert values to result map
// map[Y] = number of value occurs
for(it=tmp.begin(); it != tmp.end(); ++it)
{
y = it->second;
if(inProcents) y=(y/n)*100.0;
map.insert(pair<double, double>(it->first, y ) );
}
return map;
}
示例8: getYsum
xyMultimap_t baseXYData::GetDNL(bool arithMean, double *En, std::vector<double> *Evect)
{
xyMultimap_t map;
int i=0;
double E=0 //expected value
,ysum = getYsum()
,xmax = GetMaxX()
,x=0,y=0;
if(arithMean) E = getArithmeticMean();
else if(En) E=*En;
else if (Evect==0 ) E = ( ysum / (xmax+1) ); //default
else if (Evect->size() != m_data.size() ) return map; //must be same size
Rewind();
while( GetNextXY(x, y) )
{
if(!arithMean && Evect==0) y = y / E - 1;
else if(arithMean) y -= E;
else if(Evect) y -= (*Evect)[i++];
if(Evect){
y /= (*Evect)[i-1];
} else{
y /= E;
}
map.insert(pair<double, double>(x,y));
}
return map;
}
示例9: checkRepeatExpression
int checkRepeatExpression(char *expression)
{
Rewind();
char *first = nextToken();
char *second = nextToken();
char *third = nextToken();
char *fourth = nextToken();
char *fifth = nextToken();
if (checkREPEAT(first, strlength(first))&&
checkN(second, strlength(second))&&
checkTIMES(third, strlength(third))&&
checkCommandList(fourth, strlength(fourth))&&
checkEND(fifth, strlength(fifth)))
{
free(first);
free(second);
free(third);
free(fourth);
free(fifth);
return 1;
} else
{
free(first);
free(second);
free(third);
free(fourth);
free(fifth);
return 0;
}
return 1;
}
示例10: Rewind
HRESULT
SoundD3D::Play()
{
if (IsPlaying()) return S_OK;
if (!buffer) return E_FAIL;
HRESULT hr = E_FAIL;
if (IsDone())
hr = Rewind();
if (IsReady()) {
if (moved)
Localize();
if (flags & LOOP || flags & STREAMED)
hr = buffer->Play(0, 0, DSBPLAY_LOOPING);
else
hr = buffer->Play(0, 0, 0);
if (SUCCEEDED(hr))
status = PLAYING;
}
return hr;
}
示例11: SetAsActiveMIDIInput
bool
EMInputRepository :: SetAsActiveMIDIInput(int32 p_vInputID, int32 p_vOutputID)
{
LockContainer();
try
{
Rewind();
while(Current() != NULL)
{
EMRealtimeInputDescriptor* opInput = Current();
if((opInput -> GetType() & EM_TYPE_MIDI) > 0)
{
EMRealtimeMIDIInputDescriptor* opMIDIInput =
static_cast<EMRealtimeMIDIInputDescriptor*>(opInput);
if(opMIDIInput -> GetID() == p_vInputID)
opMIDIInput -> SetActive(true, p_vOutputID);
else
opMIDIInput -> SetActive(false, 0);
}
Next();
}
}
catch(...)
{
EMDebugger("ERROR! Exception while setting active MIDI track!");
}
UnlockContainer();
return true;
}
示例12: Rewind
void hsStream::SetPosition(uint32_t position)
{
if (position == fPosition)
return;
Rewind();
Skip(position);
}
示例13: LockContainer
int64 EMMediaClipRepository::CountClipsForTrack(const EMMediaTrack* p_opTrack, EMMediaType p_eSpecType)
{
int64 vCount = 0;
LockContainer();
try
{
Rewind();
while(Current() != NULL)
{
if(Current() -> GetTrack() -> GetID() == p_opTrack -> GetID() &&
! Current() -> IsObjectDeleted() && (p_eSpecType & Current() -> GetType()) != 0)
vCount++;
if(Current() -> GetTrack() == NULL)
EMDebugger("ERROR! NULL as track owner!");
Next();
}
}
catch(...)
{
EMDebugger("ERROR! Exception in EMMediaClipRepository::CountClipsForTrack");
}
UnlockContainer();
return vCount;
}
示例14: vsAssert
void
vsDisplayList::ApplyOffset(const vsVector2D &offset)
{
vsAssert( !m_instanceParent, "Tried to apply an offset to an instanced display list!" );
vsTransform2D currentTransform;
Rewind();
op *o = PopOp();
while(o)
{
if ( o->type == OpCode_VertexArray )
{
vsVector3D pos;
int count = o->data.GetUInt();
float *shuttle = (float *) o->data.p;
for ( int i = 0; i < count; i++ )
{
shuttle[0] += offset.x;
shuttle[1] += offset.y;
shuttle += 3;
}
}
o = PopOp();
}
}
示例15: string
VolumeRoster::VolumeRoster(const char* options)
{
// TODO:
std::string string("export LC_ALL=C; ");
string.append("df ").append(options);
CommandStreamBuffer df(string.c_str(), "r");
std::istream stream(&df);
std::string line;
std::getline(stream, line); // Skip the first line
while (std::getline(stream, line)) {
std::istringstream iss(line);
volume_info info;
std::string dummy;
iss >> info.name;
iss >> info.total;
iss >> dummy;
iss >> info.free;
iss >> dummy;
iss >> info.type;
// TODO: filesystem, other
fItems.push_back(info);
}
Rewind();
}