예제 #1
0
파일: NBBST.hpp 프로젝트: Kampbell/btrees
bool NBBST<T, Threads>::remove(T value){
    int key = hash(value);

    SearchResult search;

    while(true){
        Search(key, &search);
        nodes.publish(search.l, 0);
        
        if(search.l->key != key){
            return false;
        }

        if(getState(search.gpupdate) != CLEAN){
            Help(search.gpupdate);
        } else if(getState(search.pupdate) != CLEAN){
            Help(search.pupdate);
        } else {
            infos.publish(search.gp->update, 0);
            infos.publish(search.gpupdate, 1);

            Info* op = newDInfo(search.gp, search.p, search.l, search.pupdate);
            infos.publish(op, 2);

            Update result = search.gp->update;
            if(CASPTR(&search.gp->update, search.gpupdate, Mark(op, DFLAG))){
                if(search.gpupdate){
                    infos.releaseNode(Unmark(search.gpupdate));
                }
                
                infos.releaseAll();

                if(HelpDelete(op)){
                    nodes.releaseAll();
                    
                    return true;
                }
            } else {
                infos.releaseNode(op);
                infos.releaseAll();

                Help(result);
            }
        }
        
        nodes.releaseAll();
    }
}
예제 #2
0
파일: Cfg.c 프로젝트: BIGbozi/SoftEtherVPN
// Search for an item
ITEM *CfgFindItem(FOLDER *parent, char *name)
{
	ITEM *t, tt;
	// Validate arguments
	if (parent == NULL || name == NULL)
	{
		return NULL;
	}

	tt.Name = ZeroMalloc(StrLen(name) + 1);
	StrCpy(tt.Name, 0, name);
	t = Search(parent->Items, &tt);
	Free(tt.Name);

	return t;
}
예제 #3
0
// Search in the ARP table
L3ARPENTRY *L3SearchArpTable(L3IF *f, UINT ip)
{
	L3ARPENTRY *e, t;
	// Validate arguments
	if (f == NULL || ip == 0 || ip == 0xffffffff)
	{
		return NULL;
	}

	Zero(&t, sizeof(t));
	t.IpAddress = ip;

	e = Search(f->ArpTable, &t);

	return e;
}
bool DeleteClient(LINKEDLIST * pList, SOCKET DeleteSocket)
{
	if (pList->iCount)
	{
		return false;
	}
	NODE*pSearch = Search(pList, EqualFunc, (void*)DeleteSocket);
	if (pSearch)
	{
		SOCKET ClientSocket = (SOCKET)pSearch->pData;
		DeleteAt(pList, pSearch);
		SendPacket(ClientSocket, PG_FAIL,"로그아웃\n", 128);
		return true;
	}
	return false;
}
예제 #5
0
BOOL PathArray::RegisterPath(const void *path)
{
	if (!path || !GetChar(path, 0)) return	FALSE;

	int len = strlenV(path);

	if ((flags & ALLOW_SAME) == 0 && Search(path, MakeHashId(path, len))) return FALSE;

#define MAX_ALLOC	100
	if ((num % MAX_ALLOC) == 0) {
		pathArray = (PathObj **)realloc(pathArray, (num + MAX_ALLOC) * sizeof(void *));
	}
	SetPath(num++, path, len);

	return	TRUE;
}
예제 #6
0
bool DBRootNode::UpdateNode( const string& nodeName, const string& attributeName, int xValue, int yValue )
{
    DBNode* thisNode = Search( nodeName );
    if ( thisNode != NULL )
    {
        DBVector2D* thisAttribute = dynamic_cast<DBVector2D*>( thisNode->GetAttribute( attributeName ) );
        if ( thisAttribute != NULL )
        {
            thisAttribute->SetX( xValue );
            thisAttribute->SetY( yValue );
            return true;
        }
    }

    return false;
}
예제 #7
0
BOOL PathArray::RegisterPath(const WCHAR *path)
{
	if (!path || !path[0]) return	FALSE;

	int len = (int)wcslen(path);

	if ((flags & ALLOW_SAME) == 0 && Search(path, MakeHashId(path, len))) return FALSE;

#define MAX_ALLOC	100
	if ((num % MAX_ALLOC) == 0) {
		pathArray = (PathObj **)realloc(pathArray, (num + MAX_ALLOC) * sizeof(WCHAR *));
	}
	SetPath(num++, path, len);

	return	TRUE;
}
예제 #8
0
STDMETHODIMP COleObjectPropertyDual::ConsiderSearch(BSTR bstrToMatch, 
	SEARCHMODE rgFlags, ULONG ulCnt)
{
CComBool fCanSearch;

	_ASSERTE(m_fSearchAble);	// muß suchen können

	COM_TRY {
	WDSearchAbleObjectProperty Search(m_ObjProp);

		THROW_FAILED_HRESULT(Search -> ConsiderSearch(bstrToMatch, 
			GetSearchMode(rgFlags), &fCanSearch));

	} COM_CATCH;
	return fCanSearch ? S_OK : E_NOTIMPL;
}
예제 #9
0
파일: 1060.cpp 프로젝트: DrhF/timus-ural
int main(){
	dir[1][0]=0,dir[2][0]=0,dir[3][0]=1,dir[4][0]=-1;
	dir[1][1]=1,dir[2][1]=-1,dir[3][1]=0,dir[4][1]=0;
 
	for (int i=1;i<=4;i++) scanf("%s",&ch[i]);
	for (int i=1;i<=4;i++)
		for (int j=1;j<=4;j++) s[i][j]=(ch[i][j-1]=='b');
 
	ans=2134000000;
	Search(1);
 
	if (tt)	printf("%d\n",ans);
	else	printf("Impossible\n");
 
	return 0;
}
예제 #10
0
// Get the interface that is connected to the specified Virtual HUB from the L3 switch
L3IF *L3SearchIf(L3SW *s, char *hubname)
{
	L3IF t, *f;
	// Validate arguments
	if (s == NULL || hubname == NULL)
	{
		return NULL;
	}

	Zero(&t, sizeof(t));
	StrCpy(t.HubName, sizeof(t.HubName), hubname);

	f = Search(s->IfList, &t);

	return f;
}
예제 #11
0
파일: Cfg.c 프로젝트: BIGbozi/SoftEtherVPN
// Search a folder
FOLDER *CfgFindFolder(FOLDER *parent, char *name)
{
	FOLDER *f, ff;
	// Validate arguments
	if (parent == NULL || name == NULL)
	{
		return NULL;
	}

	ff.Name = ZeroMalloc(StrLen(name) + 1);
	StrCpy(ff.Name, 0, name);
	f = Search(parent->Folders, &ff);
	Free(ff.Name);

	return f;
}
예제 #12
0
bool QATree::CreateQuestionAnswer(string newQuestion, string newAnswer,
                                  string alternativeQA)
{
    int key = 0;
    bool created = false;

    if (root == NULL)
    {
        Insert(newQuestion, 0);
        Insert(newAnswer, 1);
        Insert(alternativeQA, -1);

		created = true;
    }
    else
    {
        if (ScalingRequired(root))
        {
            nodeScale++;
            ScaleNodes(root, nodeScale);
        }

        /* Search for the alternate answer. Store off the key if it is found */
        if (Search(alternativeQA, key))
        {
            if (IsLeaf(key))
            {
                /* Replace the existing alternate answer with a new question*/
                ReplaceInfo(key, newQuestion);
             
                /* Insert the presumably correct answer to the right of the answer */
                Insert(newAnswer, key + 1);

                /* Insert the existing, alternative answer to the left of the answer */
                Insert(alternativeQA, key - 1);

                created = true;
            }
            else
                cout << "Error: \"" << alternativeQA << "\" is a question." << endl;
        }
        else
            cout << "Error: Unable to find answer: \"" << alternativeQA << "\"." << endl;
    }

    return created;
}
double Trie::GetFreq (char * word , char *pos )
{
	PWORDTYPE w=Search (word);
	PPOSFREQCHAIN pf;
	if(!w) return 0;
	if(pos==NULL)//get the sum of freq
	{
		return w->freq;
	}else{
		for(pf=w->posfreq;pf&&strcmp(pf->pos,pos)<0;pf=pf->next);
		if(pf&&!strcmp(pf->pos,pos))
		{//find
			return pf->freq;
		}
	}
	return 0;
}
void brelse_proc(int ac, char *av[]){
  if(!initnum){
    printf("Error! Nothing is started\n");
    printf("You should call init first\n");
    return;
  }
  if(ac <= 1){
    printf("COMMON MAN, WHICH BLOCK ARE YOU TALKING ABOUT\n");
    printf("You Should Specify the block number BY YOURSELF SITTY ASS\n");
  }
  else if(ac >=3){
    printf("Too much argument\n");
  }
  else{
    int checker = 0;
    for(int i = 0; i < strlen(av[1]); i++){
      if(isalpha(av[1][i])){
	  checker++;
	}
    }
    if(!checker){
      int t = atoi(av[1]);
      if(Search(t)){
	buf *p = Clone(t);
	brelse(p);
      }
      else{
	printf("Error!, there is no such block num in the hash\n");
      }
    }
    else{
      printf("Error!, you should not include any alphabet in your input\n");
      printf("Maybe you are PUSSY\n");
    }

    /*
    if(!isalpha(atoi(av[1]))){
      buf *p = Clone(atoi(av[1]));
      brelse(p);
    }
    else{
      printf("INPUT VALUE MUST BE NUMBER, ASS WHOLE\n");
    }
    */
  }
}
int main()
{
	int i;
	scanf("%d%d",&n,&M);
	for(i=1;i<=n;i++)
		scanf("%d",&m[i]);
	for(i=1;i<=n;i++)
		scanf("%d",&v[i]);
	MaxFun();
	Search();
	Print(x,y);
	printf("%d\n",num);
	for(i=0;i<num-1;i++)
		printf("%d ",output[i]);
	printf("%d\n",output[i]);
	return 0;
}
예제 #16
0
	IthGlyph* InsertGlyph(HDC hDC, wchar_t ch)
	{
#ifndef GLYPH_NO_CACHING	
		TreeNode<wchar_t, DWORD> *p;
		p=Search(ch);
		if (p) return glyph_ptr_table[p->data];	
#endif
		IthGlyph* g=new IthGlyph(hDC);
		g->InitGlyph(ch);
#ifndef GLYPH_NO_CACHING
		Insert(ch, count);
		if (count*sizeof(IthGlyph*)==size) ReallocGlyphTable();
		glyph_ptr_table[count]=g;
		count++;
#endif
		return g;
	}
예제 #17
0
int main()
{
	int i,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&x);
	Creat(p);
	Search(p,x);
	if(flag==2)
		printf("%d",t);
	else
		printf("-1");
	return 0;
}
예제 #18
0
void    Search ( int U , int size )
{
        if ( U == 0 ) {
                if ( size > Max ) Max = size , found = true;
                return;
        }
        
        int     len , i;
        for ( len = i = 0; i < N; i ++ ) if ( U & Pow [i] ) len ++;
        if ( len + size <= Max ) return;
        for ( i = 0; U; i ++ ) if ( U & Pow [i] ) {
                if ( size + c [i] <= Max ) return;
                U -= Pow [i];
                Search ( U & graph [i] , size + 1 );
                if ( found ) return;
        }
}
예제 #19
0
main ()
{
        int     i , j;
        for ( i = 0; i < 20; i ++ ) Pow [i] = 1 << i;
        
        while ( init () ) {
                WorkForGraph ();

                Max = 0;
                for ( i = N - 1 , j = 0; i >= 0; j |= Pow [i --] ) {
                        found = false;
                        Search ( j & graph [i] , 1 );
                        c [i] = Max;
                }
                printf ( "Minimum Number of Pieces to be removed: %d\n" , N - Max );
        }
}
예제 #20
0
//---------------------------------------------------------
bool CSG_Network::Update(void)
{
	int		iEdge;

	//-----------------------------------------------------
	for(iEdge=m_Edges.Get_Count()-1; iEdge>=0; iEdge--)
	{
		CSG_Shape	*pEdge	= m_Edges.Get_Shape(iEdge);

		if( !(((CSG_Shape_Line *)pEdge)->Get_Length() > 0.0) )
		{
			m_Edges.Del_Shape(iEdge);
		}
	}

	//-----------------------------------------------------
	for(int i=0; i<Get_Node_Count(); i++)
	{
		delete(&Get_Node(i));
	}

	m_Nodes.Set_Array(0);

	//-----------------------------------------------------
	CSG_PRQuadTree	Search(m_Edges.Get_Extent());

	for(iEdge=0; iEdge<m_Edges.Get_Count(); iEdge++)
	{
		CSG_Shape	*pEdge	= m_Edges.Get_Shape(iEdge);

		pEdge->Set_Value(0, iEdge);

		pEdge->Set_Value(1, _Add_Node(Search, iEdge,
			pEdge->Get_Point(0),
			pEdge->Get_Point(1)
		));

		pEdge->Set_Value(2, _Add_Node(Search, iEdge,
			pEdge->Get_Point(pEdge->Get_Point_Count(0) - 1),
			pEdge->Get_Point(pEdge->Get_Point_Count(0) - 2)
		));
	}

	//-----------------------------------------------------
	return( true );
}
예제 #21
0
bool ColourBlendMap::Compute(TransColour& colour, DBL value, const Vector3d& TPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread)
{
    const BlendMapEntry<TransColour>* Prev;
    const BlendMapEntry<TransColour>* Cur;
    DBL prevWeight;
    DBL curWeight;
    Search (value, Prev, Cur, prevWeight, curWeight);
    if (Prev == Cur)
    {
        colour = Cur->Vals;
    }
    else
    {
        Blend(colour, Prev->Vals, prevWeight, Cur->Vals, curWeight, Thread);
    }
    return true;
}
void
SyGFindFileDialog::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == itsSearchButton && message.Is(JXButton::kPushed))
		{
		if (Search() && !itsStayOpenCB->IsChecked())
			{
			Deactivate();
			}
		}
	else if (sender == itsCloseButton && message.Is(JXButton::kPushed))
		{
		(GetWindow())->KillFocus();
		Deactivate();
		}
	else if (sender == itsHelpButton && message.Is(JXButton::kPushed))
		{
		(SyGGetManPageDialog())->ViewManPage("find");
		}

	else if (sender == itsChoosePathButton && message.Is(JXButton::kPushed))
		{
		itsPathInput->ChoosePath("");
		}

	else if (sender == itsActionRG && message.Is(JXRadioGroup::kSelectionChanged))
		{
		UpdateDisplay();
		}

	else if ((sender == itsFileInput || sender == itsExprInput) &&
			 (message.Is(JTextEditor::kTextSet) ||
			  message.Is(JTextEditor::kTextChanged)))
		{
		UpdateButtons();
		}

	else
		{
		JXWindowDirector::Receive(sender, message);
		}
}
예제 #23
0
void Search(Unit unit[], char name[], int i)
{
	if (unit[i].name == NULL)
		return;

	if (strcmp(unit[i].name, name) == 0)
	{
		printf("\n Name : %s\n", unit[i].name);
		printf("   Hp : %.2lf\n", unit[i].hp);
		printf("   Mp : %.2lf\n", unit[i].mp);
		printf("Speed : %d\n", unit[i].speed);
		printf("Range : %d\n", unit[i].range);
		printf("Posit : %s\n", unit[i].position);
	}
	else
		Search(unit, name, i + 1);
}
int main()
{
    int n,i;
	int space = 1,temp = 0,flag;
	char c;
    while((c = getchar()) != '\n')
    {
        if(c == ' '){
			t2[space] = temp;
			space++;
			temp = 0;
			flag = 0;
		}
		else{
			flag = 1;
			temp = temp * 10 + c - 48;
		}

	}
	if(flag){
		t2[space] = temp;
	}
	space = 1;
	temp = 0;
	while((c = getchar()) != '\n')
    {
        if(c == ' '){
			t1[space] = temp;
			space++;
			temp = 0;
			flag = 0;
		}
		else{
			flag = 1;
			temp = temp * 10 + c - 48;
		}

	}
	if(flag){
		t1[space] = temp;
	}
	n = space;
    Search(n,1,n,1);//因为后序最后遍历的是根节点,所以这里和前面的开始点不同,注意一下

    return 0;
}
예제 #25
0
void Agent::Update(float a_deltaTime)
{
	// Update the velocity with the current acceleration
	m_movementInfo.m_velocityX += m_movementInfo.m_accelerationX;
	m_movementInfo.m_velocityY += m_movementInfo.m_accelerationY;

	// constrain the velocity
	if (m_movementInfo.m_velocityX > m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityX = m_movementInfo.m_maxSpeed;
	}
	else if (m_movementInfo.m_velocityX < -m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityX = -m_movementInfo.m_maxSpeed;
	}
	if (m_movementInfo.m_velocityY > m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityY = m_movementInfo.m_maxSpeed;
	}
	else if (m_movementInfo.m_velocityY < -m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityY = -m_movementInfo.m_maxSpeed;
	}
	
	// set rotation
	m_movementInfo.m_rotation = atan2(m_movementInfo.m_velocityY, m_movementInfo.m_velocityX) + (float)M_PI / 2.0f;

	// reset the acceleration for the next frame
	m_movementInfo.m_accelerationX = 0.0f;
	m_movementInfo.m_accelerationY = 0.0f;

	// add the velocity to the position
	m_movementInfo.m_positionX += m_movementInfo.m_velocityX;
	m_movementInfo.m_positionY += m_movementInfo.m_velocityY;

	CheckCollisions();
	switch (GetColour())
	{
	case Colour::Green: Patrol(); break;
	case Colour::Blue: Health(); break;
	case Colour::Red: Attack(); break;
	case Colour::Orange: Search(); break;
	}
	
}
예제 #26
0
int main()
{
	int i;
	BiTreeNode *q[MaxSize+1];
	BiTreeNode *root;
	int left,right,temp;
	int Num[MaxSize]={0};
	char strA[MaxSize]="befcgdh";//pre_order
	char strB[MaxSize]="febgchd";//in_order
	char point;int n;
	n=strlen(strA);
	Initiate(&root);
	for(i=0;i<n;i++)
	{
		point=strA[i];
		temp=Search(strB,point);
		left=SearchLeft(Num,temp);
		right=SearchRight(Num,temp);
		if(left==-1&&right==-1)
		{
			q[temp]=InsertLeftNode(root,point);
			Num[temp]=1;
		}
		else if(left!=-1&&q[left]->rightChild==NULL)
		{
			q[temp]=InsertRightNode(q[left],point);
			Num[temp]=1;
		}
		else if(right!=-1&&q[right]->leftChild==NULL)
		{
			q[temp]=InsertLeftNode(q[right],point);
			Num[temp]=1;
		}
	}
	PrintBiTree(root,0);
	printf("****************************************\n\n");
	printf("PreOrder: \t");
	PreOrder(root->leftChild,Visit);
	printf("\nInOrder:\t");
	InOrder(root->leftChild,Visit);
	printf("\nPostOrder: \t");
	PostOrder(root->leftChild,Visit);
	printf("\n*****************************************************************************\n\t\t\t\bCopyright @ 2009 Gary All Right Reserved\n");
	return 0;
}
void solve ()
{
     int   i , j , k , x , y , tx , S;
     for ( i = 0; i < N; i ++ ) for ( j = 0; j < N; j ++ ) Min [i] [j] = 0x7fffffff , Max [i] [j] = -1;
     
     Min [7] [7] = Max [7] [7] = 0;
     for ( i = 6; i >= 0; i -- ) Min [i] [7] = Max [i] [7] = Min [i + 1] [7] + map [i + 1] [7];
     
     for ( j = 7; j; j -- ) {
         for ( i = 0; i < N; i ++ ) {
             for ( k = 0; k < 3; k ++ ) {
                 x = i + dx [k] , y = j + dy [k];
                 if ( !range ( x , y ) || Min [i] [j] + map [i] [j] >= Min [x] [y] ) continue;
                 Min [x] [y] = Min [i] [j] + map [i] [j];
                 for ( tx = x + 1; range ( tx , y ) && Min [tx - 1] [y] + map [tx - 1] [y] < Min [tx] [y]; tx ++ )
                     Min [tx] [y] = Min [tx - 1] [y] + map [tx - 1] [y];
                 for ( tx = x - 1; range ( tx , y ) && Min [tx + 1] [y] + map [tx + 1] [y] < Min [tx] [y]; tx -- )
                     Min [tx] [y] = Min [tx + 1] [y] + map [tx + 1] [y];
             }
         }
     }
     
     
     for ( j = 7; j; j -- ) {
         for ( i = 0; i < N; i ++ ) {
             for ( k = 0; k < 3; k ++ ) {
                 x = i + dx [k] , y = j + dy [k];
                 if ( !range ( x , y ) ) continue;
                 if ( Max [i] [j] + map [i] [j] > Max [x] [y] )
                    Max [x] [y] = Max [i] [j] + map [i] [j];
                    
                 S = Max [i] [j] + map [i] [j] + map [x] [y];
                 for ( tx = x + 1; range ( tx , y ); S += map [tx] [y] , tx ++ )
                     if ( S > Max [tx] [y] ) Max [tx] [y] = S;
                 S = Max [i] [j] + map [i] [j] + map [x] [y];
                 for ( tx = x - 1; range ( tx , y ); S += map [tx] [y] , tx -- )
                     if ( S > Max [tx] [y] ) Max [tx] [y] = S;
             }
         }
     }     
   
     memset ( mark , 0 , sizeof ( mark )); mark [0] [0] = true;
     if ( Search ( 0 , 0 , map [0] [0] )) printf ( "Yes\n" );
     else printf ( "No\n" );
}
예제 #28
0
void VSCMainWindows::SetupConnections()
{
	connect(m_pMainArea, SIGNAL(tabCloseRequested(int)), this, SLOT(MainCloseTab(int)));
	connect(m_pDeviceList, SIGNAL(SurveillanceClicked()), this, SLOT(AddSurveillance()));
	connect(m_pDeviceList, SIGNAL(CameraAddClicked()), this, SLOT(AddCamera()));
	connect(m_pDeviceList, SIGNAL(EmapClicked()), this, SLOT(AddEmap()));
	connect(m_pDeviceList, SIGNAL(DminingClicked()), this, SLOT(AddDmining()));
	connect(m_pDeviceList, SIGNAL(SearchClicked()), this, SLOT(Search()));
	connect(m_pDeviceList, SIGNAL(RecorderClicked()), this, SLOT(AddRecorder()));


	connect(m_pDeviceList, SIGNAL(CameraEditClicked(int)), this, SLOT(EditCamera(int)));
	connect(m_pDeviceList, SIGNAL(CameraDeleteClicked(int)), this, SLOT(DeleteCamera(int)));

	/* VIPC */
	connect(m_pDeviceList, SIGNAL(VIPCAddClicked()), this, SLOT(AddVIPC()));
	connect(m_pDeviceList, SIGNAL(VIPCEditClicked(int)), this, SLOT(EditVIPC(int)));
	connect(m_pDeviceList, SIGNAL(VIPCDeleteClicked(int)), this, SLOT(DeleteVIPC(int)));

	/* Camera Group */
	connect(m_pDeviceList, SIGNAL(VGroupAddClicked()), this, SLOT(AddVGroup()));
	connect(m_pDeviceList, SIGNAL(VGroupEditClicked(int)), this, SLOT(EditVGroup(int)));
	connect(m_pDeviceList, SIGNAL(VGroupDeleteClicked(int)), this, SLOT(DeleteVGroup(int)));
	connect(m_pDeviceList, SIGNAL(VGroupMapClicked()), this, SLOT(MapVGroup()));


	/* Disk edit */
	connect(m_pDeviceList, SIGNAL(DiskEditClicked()), this, SLOT(EditDisk()));

	/* View */
	connect(m_pDeviceList, SIGNAL(ViewDeleteClicked(int)), this, SLOT(DeleteView(int)));

	/* VMS */
	connect(m_pDeviceList, SIGNAL(VMSDeleteClicked(int)), this, SLOT(DeleteVMS(int)));


	//connect(this, SIGNAL(CameraDeleted()), m_pDeviceList, SLOT(CameraTreeUpdated()));
	connect(m_pToolBar->ui.pbFullScreen, SIGNAL(clicked()), this, SLOT(SetFullScreen()));
	connect(m_pToolBar->ui.pbAbout, SIGNAL(clicked()), this, SLOT(about()));
	connect(m_pToolBar->ui.pbAlarm, SIGNAL(clicked()), this, SLOT(AddEvent()));
	connect(m_pToolBar->ui.pbSetting, SIGNAL(clicked()), this, SLOT(Setting()));
	connect(m_pToolBar->ui.pbUser, SIGNAL(clicked()), this, SLOT(UserStatus()));
	connect(m_pEventThread, SIGNAL(EventNotifyNoParam()), m_pToolBar, SLOT(NewAlarm()));

}
예제 #29
0
void RedBlackTree::Delete(uint32_t key)
{
    
    RedBlackNode::Ptr z = Search(key);
    RedBlackNode::Ptr x;
    if(z == nil)
        return;
    
    RedBlackNode::Ptr y = z;
    RedBlackNode::color_t original_color = y->Color();
    if(z->Left() == nil)
    {
        x = z->Right();
        Transplant(z,z->Right());
    }
    else if(z->Right() == nil)
    {
        x = z->Left();
        Transplant(z,z->Left());
    }
    else
    {
        y = Minimum(z->Right());
        original_color = y->Color();
        x = y->Right();
        if(y->Parent() == z)
        {
            x->Parent(y);
        }
        else
        {
            Transplant(y,y->Right());
            y->Right(z->Right());
            y->Right()->Parent(y);
        }
        Transplant(z,y);
        y->Left(z->Left());
        y->Left()->Parent(y);
        y->Color(z->Color());
    }
    if(original_color == RedBlackNode::BLACK)
    {
        Delete_Fixup(x);
    }
}
예제 #30
0
파일: Cfg.c 프로젝트: BIGbozi/SoftEtherVPN
// Create a folder
FOLDER *CfgCreateFolder(FOLDER *parent, char *name)
{
	UINT size;
	FOLDER *f;
	// Validate arguments
	if (name == NULL)
	{
		return NULL;
	}

	size = StrLen(name) + 1;

#ifdef	CHECK_CFG_NAME_EXISTS

	// Check the name in the parent list
	if (parent != NULL)
	{
		FOLDER ff;
		ff.Name = ZeroMalloc(size);
		StrCpy(ff.Name, 0, name);
		f = Search(parent->Folders, &ff);
		Free(ff.Name);
		if (f != NULL)
		{
			// Folder with the same name already exists
			return NULL;
		}
	}

#endif	// CHECK_CFG_NAME_EXISTS

	f = ZeroMalloc(sizeof(FOLDER));
	f->Items = NewListFast(CmpItemName);
	f->Folders = NewListFast(CmpFolderName);
	f->Name = ZeroMalloc(size);
	StrCpy(f->Name, 0, name);
	f->Parent = parent;

	// Add to parentlist
	if (f->Parent != NULL)
	{
		Insert(f->Parent->Folders, f);
	}
	return f;
}