本文整理汇总了C++中reverse函数的典型用法代码示例。如果您正苦于以下问题:C++ reverse函数的具体用法?C++ reverse怎么用?C++ reverse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reverse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: goSomewhere
//.........这里部分代码省略.........
move_robot(s, 1, 1);
ns = copy(s);
do{
free(s);
s = copy(ns);
update_world(ns, s);
change++;
stage++;
end = 0;
for(i=1; i <= s->world_w; i++){
for(j=1; j <= s->world_h; j++){
if(c[point_to_index(s,i,j)]==stage){
if(get(s, i, j) == O_LIFT_OPEN || get(s, i, j) == O_LAMBDA){
wx=i;
wy=j;
end=stage;
break;
}
//consider four cells - (-1, 0), (1, 0), (0, -1), (0, 1)
for(k = 1; k<=4; k++){
if(k==1) {is= 0 ; js=-1;}
if(k==2) {is= 0 ; js= 1;}
if(k==3) {is=-1 ; js= 0;}
if(k==4) {is= 1 ; js= 0;}
if(bounded(s,i+is,j+js) && c[point_to_index(s, i+is, j+js)]==UINT_MAX){
//can we go there?
if( !bounded(s, i+is, j+js+1) || (get(s, i+is, j+js+1) != O_EMPTY || get(ns, i+is, j+js+1) != O_ROCK)){
if(get(s, i+is, j+js)==O_LIFT_OPEN
|| get(s, i+is, j+js)==O_LAMBDA
|| get(s, i+is, j+js)==O_EARTH
|| get(s, i+is, j+js)==O_EMPTY){
if((bounded(s, i+is, j+js+1) && get(s, i+is, j+js+1)==O_ROCK)
|| (bounded(s, i+is+1, j+js+1) && get(s, i+is+1, j+js)==O_ROCK && get(s, i+is+1, j+js+1)==O_ROCK)
|| (bounded(s, i+is-1, j+js+1) && get(s, i+is-1, j+js)==O_ROCK && get(s, i+is-1, j+js+1)==O_ROCK)){
c[point_to_index(s, i+is, j+js)]=stage+penalty;
}else{
c[point_to_index(s, i+is, j+js)]=stage+1;
}
change = 0;
}
}
}
}
}
}
}
}while(change <= penalty && end == 0);
//debug
//dump(s);
if(0){
for(j=s->world_h; j>0; j--){
for(i=1; i<=s->world_w; i++){
if(c[point_to_index(s, i, j)]==UINT_MAX){
printf("X");
}else{
printf("%u", c[point_to_index(s, i, j)]);
}
}
printf("\n");
}
printf("\n");
}
i=0;
if(end>0){
answer = malloc( (end+2)*sizeof( char ));
if (answer == NULL ){}
while(end>0){
for(k=1; k<=4;k++){
if(k==1) {is=-1; js= 0;move='R';}
if(k==2) {is= 1; js= 0;move='L';}
if(k==3) {is= 0; js=-1;move='U';}
if(k==4) {is= 0; js= 1;move='D';}
if( bounded(s, wx+is, wy+js) && c[point_to_index(s, wx+is, wy+js)] < end) {
end = c[point_to_index(s, wx+is, wy+js)];
answer[i++]=move;
wx = wx+is;
wy = wy+js;
break;
}
}
}
answer[i]='\0';
reverse(answer,0,strlen(answer)-1);
}else{
answer = malloc(1*sizeof( char ));
if (answer == NULL ){}
answer[0]='\0';
*a=answer;
free(c);
return 1;
}
*a=answer;
free(c);
return 0;
}
示例2: fopen
int B011001::loadTextureBMP(char* file)
{
unsigned int texture_ID;
FILE* file_Pointer;
unsigned short magic; // Image magic
unsigned int dx,dy,size; // Image dimensions
unsigned short nbp,bpp; // Planes and bits per pixel
unsigned char* image; // Image data
unsigned int k; // Counter
// Open file
file_Pointer = fopen(file,"rb");
if (!file_Pointer) fatal("Cannot open file %s\n", file);
// Check image magic
if (fread(&magic,2,1,file_Pointer)!=1) fatal("Cannot read magic from %s\n",file);
if (magic!=0x4D42 && magic!=0x424D) fatal("Image magic not BMP in %s\n",file);
// Seek to and read header
if (fseek(file_Pointer,16,SEEK_CUR) || fread(&dx ,4,1,file_Pointer)!=1 || fread(&dy ,4,1,file_Pointer)!=1 ||
fread(&nbp,2,1,file_Pointer)!=1 || fread(&bpp,2,1,file_Pointer)!=1 || fread(&k,4,1,file_Pointer)!=1)
fatal("Cannot read header from %s\n",file);
// Reverse bytes on big endian hardware (detected by backwards magic)
if (magic==0x424D)
{
reverse(&dx,4);
reverse(&dy,4);
reverse(&nbp,2);
reverse(&bpp,2);
reverse(&k,4);
}
// Check image parameters
if (dx<1 || dx>65536) fatal("%s image width out of range: %d\n",file,dx);
if (dy<1 || dy>65536) fatal("%s image height out of range: %d\n",file,dy);
if (nbp!=1) fatal("%s bit planes is not 1: %d\n",file,nbp);
if (bpp!=24) fatal("%s bits per pixel is not 24: %d\n",file,bpp);
if (k!=0) fatal("%s compressed files not supported\n",file);
#ifndef GL_VERSION_2_0
// OpenGL 2.0 lifts the restriction that texture size must be a power of two
for (k=1;k<dx;k*=2);
if (k!=dx) fatal("%s image width not a power of two: %d\n",file,dx);
for (k=1;k<dy;k*=2);
if (k!=dy) fatal("%s image height not a power of two: %d\n",file,dy);
#endif
// Allocate image memory
size = 3*dx*dy;
image = (unsigned char*) malloc(size);
if (!image) fatal("Cannot allocate %d bytes of memory for image %s\n",size,file);
// Seek to and read image
if (fseek(file_Pointer,20,SEEK_CUR) || fread(image,size,1,file_Pointer)!=1) fatal("Error reading data from image %s\n",file);
fclose(file_Pointer);
// Reverse colors (BGR -> RGB)
for (k=0;k<size;k+=3)
{
unsigned char temp = image[k];
image[k] = image[k+2];
image[k+2] = temp;
}
// Generate 2D texture
glGenTextures(1,&texture_ID);
glBindTexture(GL_TEXTURE_2D,texture_ID);
// Copy image
glTexImage2D(GL_TEXTURE_2D,0,3,dx,dy,0,GL_RGB,GL_UNSIGNED_BYTE,image);
if (glGetError()) fatal("Error in glTexImage2D %s %dx%d\n",file,dx,dy);
// Scale linearly when image size doesn't match
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
// Free image memory
free(image);
// Return texture name
return texture_ID;
}
示例3: reversed_binary_value
int reversed_binary_value(...)
{
return reverse(sizeof...(digits), digits...);
}
示例4: while
// performs the backtrace algorithm
void CBandedSmithWaterman::Traceback(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2, unsigned int bestRow, unsigned int bestColumn, const unsigned int rowOffset, const unsigned int columnOffset){
unsigned int currentRow = bestRow;
unsigned int currentColumn = bestColumn;
unsigned int currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);
// record the numbers of row and column before the current row and column
unsigned int previousRow = bestRow;
unsigned int previousColumn = bestColumn;
unsigned int gappedAnchorLen = 0;
unsigned int gappedQueryLen = 0;
unsigned int numMismatches = 0;
bool keepProcessing = true;
while(keepProcessing) {
unsigned int nVerticalGap = 0;
unsigned int nHorizontalGap = 0;
switch(mPointers[currentPosition].Direction){
case Directions_DIAGONAL:
nVerticalGap = mPointers[currentPosition].mSizeOfVerticalGaps;
for(unsigned int i = 0; i < nVerticalGap; i++){
mReversedAnchor[gappedAnchorLen++] = GAP;
mReversedQuery[gappedQueryLen++] = s2[currentRow];
numMismatches++;
previousRow = currentRow;
previousColumn = currentColumn;
currentRow--;
}
break;
case Directions_STOP:
keepProcessing = false;
//mReversedAnchor[gappedAnchorLen+1]='\0';
//mReversedQuery [gappedQueryLen+1]='\0';
break;
case Directions_UP:
mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
mReversedQuery[gappedQueryLen++] = s2[currentRow];
if(s1[currentColumn] != s2[currentRow]) numMismatches++;
previousRow = currentRow;
previousColumn = currentColumn;
currentRow--;
currentColumn--;
break;
case Directions_LEFT:
nHorizontalGap = mPointers[currentPosition].mSizeOfHorizontalGaps;
for(unsigned int i = 0; i < nHorizontalGap; i++){
mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
mReversedQuery[gappedQueryLen++] = GAP;
numMismatches++;
previousRow = currentRow;
previousColumn = currentColumn;
currentColumn--;
}
break;
}
currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);
}
// correct the reference and query sequence order
mReversedAnchor[gappedAnchorLen] = 0;
mReversedQuery [gappedQueryLen] = 0;
reverse(mReversedAnchor, mReversedAnchor + gappedAnchorLen);
reverse(mReversedQuery, mReversedQuery + gappedQueryLen);
//alignment.Reference = mReversedAnchor;
//alignment.Query = mReversedQuery;
// assign the alignment endpoints
//alignment.ReferenceBegin = previousColumn;
//alignment.ReferenceEnd = bestColumn;
referenceAl = previousColumn;
/*
if(alignment.IsReverseComplement){
alignment.QueryBegin = s2.length() - bestRow - 1;
alignment.QueryEnd = s2.length() - previousRow - 1;
} else {
alignment.QueryBegin = previousRow;
alignment.QueryEnd = bestRow;
}
*/
//alignment.QueryLength = alignment.QueryEnd - alignment.QueryBegin + 1;
//.........这里部分代码省略.........
示例5: CC_CALLBACK_2
//------------------------------------------------------------------
//
// MenuLayerMainMenu
//
//------------------------------------------------------------------
MenuLayerMainMenu::MenuLayerMainMenu()
{
_touchListener = EventListenerTouchOneByOne::create();
_touchListener->setSwallowTouches(true);
_touchListener->onTouchBegan = CC_CALLBACK_2(MenuLayerMainMenu::onTouchBegan, this);
_touchListener->onTouchMoved = CC_CALLBACK_2(MenuLayerMainMenu::onTouchMoved, this);
_touchListener->onTouchEnded = CC_CALLBACK_2(MenuLayerMainMenu::onTouchEnded, this);
_touchListener->onTouchCancelled = CC_CALLBACK_2(MenuLayerMainMenu::onTouchCancelled, this);
_eventDispatcher->addEventListenerWithFixedPriority(_touchListener, 1);
// Font Item
auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23));
auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23));
auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23));
auto item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) );
// Image Item
auto item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) );
// Label Item (LabelAtlas)
auto labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.');
auto item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) );
item3->setDisabledColor( Color3B(32,32,64) );
item3->setColor( Color3B(200,200,255) );
// Font Item
auto item4 = MenuItemFont::create("I toggle enable items", [&](Object *sender) {
_disabledItem->setEnabled(! _disabledItem->isEnabled() );
});
item4->setFontSizeObj(20);
item4->setFontName("Marker Felt");
// Label Item (LabelBMFont)
auto label = LabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt");
auto item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this));
// Testing issue #500
item5->setScale( 0.8f );
// Events
MenuItemFont::setFontName("Marker Felt");
// Bugs Item
auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));
// Font Item
auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
auto color_action = TintBy::create(0.5f, 0, -255, -255);
auto color_back = color_action->reverse();
auto seq = Sequence::create(color_action, color_back, NULL);
item7->runAction(RepeatForever::create(seq));
auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, NULL);
menu->alignItemsVertically();
// elastic effect
auto s = Director::getInstance()->getWinSize();
int i=0;
Node* child;
auto pArray = menu->getChildren();
Object* pObject = NULL;
CCARRAY_FOREACH(pArray, pObject)
{
if(pObject == NULL)
break;
child = static_cast<Node*>(pObject);
auto dstPoint = child->getPosition();
int offset = (int) (s.width/2 + 50);
if( i % 2 == 0)
offset = -offset;
child->setPosition( Point( dstPoint.x + offset, dstPoint.y) );
child->runAction(
EaseElasticOut::create(MoveBy::create(2, Point(dstPoint.x - offset,0)), 0.35f)
);
i++;
}
_disabledItem = item3; item3->retain();
_disabledItem->setEnabled( false );
addChild(menu);
menu->setPosition(Point(s.width/2, s.height/2));
}
示例6: lessPeptideInfoSort
void ProteomeInfo::sortPeptideInfoDescending( vector< PeptideInfo * > & vpPeptideInfoInput, string sKey )
{
LessPeptideInfo lessPeptideInfoSort( sKey );
sort( vpPeptideInfoInput.begin(), vpPeptideInfoInput.end(), lessPeptideInfoSort );
reverse( vpPeptideInfoInput.begin(), vpPeptideInfoInput.end() );
}
示例7: applyCC
obj applyCC( obj (*func)(obj, obj), obj v1, obj v2){
if(type(v1)==LIST && type(v2)==LIST) {
list l1=ul(v1), l2=ul(v2);
list l=nil;
for(; l1 && l2; l1=rest(l1), l2=rest(l2)){
l= cons(call_fn(func, first(l1), first(l2)), l);
}
if(l1 || l2) error("unmatched num. of elems. in the lists");
return List2v(reverse(l));
}
obj lt,rt;
if(type(v1)==tDblArray && type(v2)==tDblArray){
int len = udar(v1).size;
if(len != udar(v2).size) error("num mismatch");
obj rr = dblArray(len);
// obj rr = new dblarr(len);
double* v = udar(rr).v;
for(int i=0; i<len; i++){
lt = Double(udar(v1).v[i]);//íxÇ¢
rt = Double(udar(v2).v[i]);
obj rx = call_fnr(func, lt,rt);
// release(lt);
// release(rt);
if(type(rx)!=tDouble) error("array: type mismatch");//kore mondai
v[i] = udbl(rx);
release(rx);
}
return rr;
}
if(isVec(type(v1)) && isVec(type(v2))){
int len=size(v1);
if(len!=size(v2)) error("num mismatch");
obj rr = aArray(len);
for(int i=0; i<len; i++){
lt = ind(v1,i);
rt = ind(v2,i);
uar(rr).v[i] = call_fnr(func, lt, rt);
// release(lt);
// release(rt);
}
return rr;
}
if( type(v1)==LIST && isVec(type(v2))){
list l=nil, l1=ul(v1);
int len=size(v2);
for(int i=0; i<len; i++,l1=rest(l1)){
if(! l1) error("num mismatch");
rt = ind(v2,i);
l = cons(call_fn(func, first(l1), rt), l);
release(rt);
}
return List2v(reverse(l));
}
if( isVec(type(v1)) && type(v2)==LIST){
list l=nil, l2=ul(v2);
int len=size(v1);
for(int i=0; i<len; i++,l2=rest(l2)){
if(! l2) error("num mismatch");
lt=ind(v1,i);
l=cons(call_fn(func, lt, first(l2)), l);
release(lt);
}
return List2v(reverse(l));
}
error("operation not defined.");
return nil;
}
示例8: description
bool OBMoleculeFormat::ReadChemObjectImpl(OBConversion* pConv, OBFormat* pFormat)
{
std::istream &ifs = *pConv->GetInStream();
if (!ifs.good())
return false;
OBMol* pmol = new OBMol;
std::string auditMsg = "OpenBabel::Read molecule ";
std::string description(pFormat->Description());
auditMsg += description.substr(0,description.find('\n'));
obErrorLog.ThrowError(__FUNCTION__,
auditMsg,
obAuditMsg);
if(pConv->IsOption("C",OBConversion::GENOPTIONS))
return DeferMolOutput(pmol, pConv, pFormat);
bool ret=true;
if(pConv->IsOption("separate",OBConversion::GENOPTIONS))
{
//On first call, separate molecule and put fragments in MolArray.
//On subsequent calls, remove a fragment from MolArray and send it for writing
//Done this way so that each fragment can be written to its own file (with -m option)
if(!StoredMolsReady)
{
while(ret) //do all the molecules in the file
{
ret = pFormat->ReadMolecule(pmol,pConv);
if(ret && (pmol->NumAtoms() > 0 || (pFormat->Flags()&ZEROATOMSOK)))
{
vector<OBMol> SepArray = pmol->Separate(); //use un-transformed molecule
//Add an appropriate title to each fragment
if(SepArray.size()>1)
for(int i=0;i<SepArray.size();++i)
{
stringstream ss;
ss << pmol->GetTitle() << '#' << i+1;
string title = ss.str();
SepArray[i].SetTitle(title);
}
else
SepArray[0].SetTitle(pmol->GetTitle());
copy(SepArray.begin(),SepArray.end(),back_inserter(MolArray));
}
}
reverse(MolArray.begin(),MolArray.end());
StoredMolsReady = true;
//Clear the flags of the input stream(which may have found eof) to ensure will
//try to read anothe molecule and allow the stored ones to be sent for output.
pConv->GetInStream()->clear();
}
if(MolArray.empty()) //normal end of fragments
ret =false;
else
{
// Copying is needed because the OBMol passed to AddChemObject will be deleted.
// The OBMol in the vector is deleted here.
OBMol* pMolCopy = new OBMol( MolArray.back());
MolArray.pop_back();
ret = pConv->AddChemObject(
pMolCopy->DoTransformations(pConv->GetOptions(OBConversion::GENOPTIONS), pConv))!=0;
}
if(!ret)
StoredMolsReady = false;
delete pmol;
return ret;
}
ret=pFormat->ReadMolecule(pmol,pConv);
OBMol* ptmol = NULL;
//Molecule is valid if it has some atoms
//or the format allows zero-atom molecules and it has a title or properties
if(ret && (pmol->NumAtoms() > 0
|| (pFormat->Flags()&ZEROATOMSOK && (*pmol->GetTitle() || pmol->HasData(1)))))
{
ptmol = static_cast<OBMol*>(pmol->DoTransformations(pConv->GetOptions(OBConversion::GENOPTIONS),pConv));
if(ptmol && (pConv->IsOption("j",OBConversion::GENOPTIONS)
|| pConv->IsOption("join",OBConversion::GENOPTIONS)))
{
//With j option, accumulate all mols in one stored in this class
if(pConv->IsFirstInput())
_jmol = new OBMol;
pConv->AddChemObject(_jmol);
//will be discarded in WriteChemObjectImpl until the last input mol. This complication
//is needed to allow joined molecules to be from different files. pOb1 in AddChem Object
//is zeroed at the end of a file and _jmol is in danger of not being output.
*_jmol += *ptmol;
delete ptmol;
return true;
}
}
else
delete pmol;
//.........这里部分代码省略.........
示例9: test1
constexpr bool test1(int n) {
char stuff[100] = "foobarfoo";
const char stuff2[100] = "oofraboof";
reverse(stuff, stuff + n); // expected-note {{cannot refer to element 101 of array of 100 elements}}
return equal(stuff, stuff + n, stuff2, stuff2 + n);
}
示例10: back
void back(int foot)
{
Nova=reverse(Nova);
forward(foot);
}
示例11: right
void right(int foot)
{
Nova=reverse(Left[Nova][Head]);
forward(foot);
}
示例12: main
int main(void) {
List lista;
ListNode temp_node;
int i;
double temp_array[6];
lista = create();
if(add(&lista, 1, 10.5) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 2, 76) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 1, 63) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 3, 109.73) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 2, 1903.78) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 6, 7.5) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
// PrintAll(lista); //63, 1903.78, 10.5, 109.73, 76, 7.5
i=1;
temp_node=lista.Head;
while(i<=lista.megethos){
temp_array[i-1]=temp_node->dedomena;
i=i+1;
temp_node=temp_node->epomenos;
}
reverse(&lista);
temp_node=lista.Head;
for(i=0;i<6;i++){
if(temp_array[5-i]!=temp_node->dedomena)
break;
else{
temp_node=temp_node->epomenos;
}
}
if(i==6)
printf("OK\n");
else
printf("Error\n");
// printf("\nlista meta tin antistrofi:\n\n");
// PrintAll(lista);
// reverse(&lista);
// printf("\nlista meta tin antistrofi:\n\n");
// PrintAll(lista);
destroy(&lista);
return 1;
}
示例13: rotate
void rotate(int nums[], int n, int k) {
k = k % n;
reverse(nums, nums + n); //可以换成迭代器
reverse(nums, nums + k);
reverse(nums + k, nums + n);
}
示例14: insert_buffer
static int insert_buffer(losig_list* losig, lofig_list* lofig, int optim_level, long index)
{
double capa, init_capa;
cell_list* buffer;
chain_list* namechain, *sigchain=NULL;
char* signame;
lofig_list* model;
losig_list* losig_buf;
loins_list* loins_buf;
locon_list* locon;
losig_list* losig_vdd=NULL, *losig_vss=NULL, *losig_aux;
ptype_list* ptype, *buffer_ptype;
double delay, best_delay, init_delay;
loins_list* loins;
chain_list* lofigchain,*newlofigchain=NULL;
int buffer_is_better=0, change=1; /*flags*/
chain_list* pred;
chain_list* temp;
buffer=getCellbuffer();
/*no buffer in library*/
if (!buffer) return 0;
if (!losig->NAMECHAIN) {
fprintf(stderr,"insert_buffer: no name on signal\n");
autexit(1);
}
best_delay=critical_delay(lofig);
init_capa=getcapacitance(losig->NAMECHAIN->DATA);
/*add buffer to netlist*/
signame=getautoname(losig->NAMECHAIN->DATA);
namechain=addchain(NULL,signame);
losig_buf=addlosig(lofig,index,namechain,INTERNAL);
putcapacitance(signame,0);
putdelay(signame,0);
model=getlofig(buffer->BEFIG->NAME,'A');
/*search vdd and vss*/
for (locon=lofig->LOCON; locon; locon=locon->NEXT) {
if (isvdd(locon->NAME)) losig_vdd=locon->SIG;
if (isvss(locon->NAME)) losig_vss=locon->SIG;
}
/*build list of signal*/
for (locon=model->LOCON;locon; locon=locon->NEXT) {
if (locon->DIRECTION==UNKNOWN) {
fprintf(stderr,"BEH: 'linkage %s' in figure '%s' isn't accepted\n",
locon->NAME,model->NAME);
autexit(1);
}
if (isvdd(locon->NAME)) losig_aux=losig_vdd;
else if (isvss(locon->NAME)) losig_aux=losig_vss;
else if (locon->DIRECTION==OUT) losig_aux=losig_buf;
else if (locon->DIRECTION==IN) losig_aux=losig;
else {
fprintf(stderr,"insert_buffer: buffer port '%s' unknown\n",locon->NAME);
autexit(1);
}
sigchain=addchain(sigchain,losig_aux);
}
sigchain=reverse(sigchain);
loins_buf=addloins(lofig,signame,model,sigchain);
freechain(sigchain);
/*to check changes*/
init_delay=getdelay(losig->NAMECHAIN->DATA);
init_capa=getcapacitance(losig->NAMECHAIN->DATA);
loins_capacitance(loins_buf,1/*add capa*/);
/*lofigchain*/
for (locon=loins_buf->LOCON;locon; locon=locon->NEXT) {
if (locon->DIRECTION==UNKNOWN) {
fprintf(stderr,"BEH: 'linkage %s' in figure '%s' isn't accepted\n",
locon->NAME,loins_buf->INSNAME);
autexit(1);
}
if (isvdd(locon->NAME)) losig_aux=losig_vdd;
else if (isvss(locon->NAME)) losig_aux=losig_vss;
else if (locon->DIRECTION==OUT) losig_aux=losig_buf;
else if (locon->DIRECTION==IN) losig_aux=losig;
else {
fprintf(stderr,"insert_buffer: buffer port '%s' unknown\n",locon->NAME);
autexit(1);
}
ptype=getptype(losig_aux->USER,LOFIGCHAIN);
if (!ptype) losig_aux->USER=addptype(losig_aux->USER,LOFIGCHAIN,addchain(NULL,locon));
else ptype->DATA=addchain(ptype->DATA,locon);
}
/*move all instance after buffer*/
ptype=getptype(losig->USER,LOFIGCHAIN);
buffer_ptype=getptype(losig_buf->USER,LOFIGCHAIN);
if (!ptype || !buffer_ptype) {
fprintf(stderr,"insert_buffer: LOFIGCHAIN not found\n");
autexit(1);
}
//.........这里部分代码省略.........
示例15: isPalindrome
bool isPalindrome(unsigned int x){
return x == reverse(x);
}