Exemplo n.º 1
0
// we do not register the parent node; we  register only the children
CTrieNodeBuild* CMorphAutomatBuilder::AddSuffix(CTrieNodeBuild* pParentNodeNo, const char* WordForm)
{
	// save current char
	BYTE RelationChar = (BYTE)*WordForm;
	WordForm++;

	//  adding new node child
	CTrieNodeBuild* pChildNode = CreateNode();
	 
	//  adding the rest of the suffix 
	if (*WordForm)
		AddSuffix(pChildNode, WordForm); 

	// making it final
	if (*WordForm == 0)
		pChildNode->SetFinal( true ) ;

	//  replace or register (the children should be already registered)
	pChildNode = ReplaceOrRegister(pChildNode);
		

	//  adding this child to the parent
	{
		assert (!pParentNodeNo->m_bRegistered);
		pParentNodeNo->AddChild(pChildNode, m_Alphabet2Code[RelationChar]);
	}
	return 	pChildNode;
};
Exemplo n.º 2
0
Node *create_scene_city_bmap() {

	// casita3/house01
	// casa5/wachhaus
	// dom/dom

	Node * aux;
	list *gObj_list;
	Node *myNode;
	static trfm3D TT;

	gObj_list = CreateVoidList();

	AddLast(gObj_list, SceneRegisterGObject( "./obj/casita3/", "house01.obj"));
	AddLast(gObj_list, SceneRegisterGObject( "./obj/casa5/", "wachhaus.obj"));
	AddLast(gObj_list, SceneRegisterGObject( "./obj/dom/", "dom.obj"));

	aux = create_city(500, gObj_list);

	SetTransTrfm3D(&TT, 0, -5, 00);
	//SetTransTrfm3D(&TT, 0, 0, 0);
	myNode = CreateNode("root");
	SetTrfmNode(myNode, &TT);
	//SetShaderNode(myNode, SceneFindShader("pervertex"));
	SetShaderNode(myNode, SceneFindShader("perfragment"));
	AttachNodeScene(myNode);
	AttachNode(myNode, aux);

	aux = create_floor_city( "./obj/floor/", "cityfloor_grass.obj");
	SetShaderNode(aux, SceneFindShader("bump"));
	AttachNode(myNode, aux); // takes ownership
	return aux;
}
Exemplo n.º 3
0
/* static */
bool
PxrUsdMayaTranslatorUtil::CreateTransformNode(
        const UsdPrim& usdPrim,
        MObject& parentNode,
        const PxrUsdMayaPrimReaderArgs& args,
        PxrUsdMayaPrimReaderContext* context,
        MStatus* status,
        MObject* mayaNodeObj)
{
    static const MString _defaultTypeName("transform");

    if (not usdPrim or not usdPrim.IsA<UsdGeomXformable>()) {
        return false;
    }

    if (not CreateNode(usdPrim,
                       _defaultTypeName,
                       parentNode,
                       context,
                       status,
                       mayaNodeObj)) {
        return false;
    }

    // Read xformable attributes from the UsdPrim on to the transform node.
    UsdGeomXformable xformable(usdPrim);
    PxrUsdMayaTranslatorXformable::Read(xformable, *mayaNodeObj, args, context);

    return true;
}
Exemplo n.º 4
0
void CMorphAutomatBuilder::InitTrie()
{
	ClearBuildNodes();
	m_pRoot = CreateNode();
	ClearRegister();
	
};
Exemplo n.º 5
0
void SkinnedMeshNode::SerializeIn( std::ifstream& stream )
{
	// 이미 앞에서 타입은 읽었다.
	unsigned short ver = 0;
	unsigned char count =0 ;

	//scene
	stream.read((char*)&ver,sizeof(ver));
	ReadString(stream,m_strNodeName);
	ReadString(stream,m_strParentName);
	ReadMatrix(stream,m_nodeTM);	
	stream.read((char*)&m_materialRefIndex,sizeof(m_materialRefIndex));
	stream.read((char*)&m_materialSubIndex,sizeof(m_materialSubIndex));
	stream.read((char*)&m_primitiveCount,sizeof(m_primitiveCount));
	stream.read((char*)&m_startIndex,sizeof(m_startIndex));
	ReadBool(stream,m_bInstancingEnable);
	// mesh
	SerializeInMesh(stream);

	// child	
	stream.read((char*)&count,sizeof(count));
	for ( int i=0 ; i<count ; i++ )
	{
		SCENETYPE type;
		stream.read((char*)&type,sizeof(type));
		cSceneNode* pNode = CreateNode(type);
		pNode->SetRootNode(m_pRootNode);
		pNode->SetParentNode(this);
		pNode->SetParentName(m_strNodeName.c_str());
		AttachChildNode(pNode);
		pNode->SerializeIn(stream);		
	}
}
Exemplo n.º 6
0
int main()
{
    struct timespec start, end;
    double cpu_time;
    LinkNode *head = CreateNode();
    assert((head->next != NULL && head->next->next !=NULL) && "no cycle");
    clock_gettime(CLOCK_REALTIME, &start);
    LinkNode *res = detectCycle(head);
    clock_gettime(CLOCK_REALTIME, &end);
    cpu_time = diff_in_second(start, end);
    //use print to check the list 
    /*printf("%d->%d->%d->%d->%d->%d->%d\n",head->data,
				    head->next->data,
				    head->next->next->data,
				    head->next->next->next->data,
				    head->next->next->next->next->data,
				    head->next->next->next->next->next->data,
				    head->next->next->next->next->next->next->data);*/
    if (res != NULL)
	//printf("result: n%d\n",res->data);
	printf("execution time: %.10lf sec\n", cpu_time);
    else
	printf("NULL\n");
    return 0;
}
Exemplo n.º 7
0
CL_HeapBTreeNodeSpace::CL_HeapBTreeNodeSpace (short order, const
                                              CL_GenericBTree& tree,
                                              CL_AbstractComparator& cmp)
: CL_BTreeNodeSpace (order, tree, cmp)
{
    _root = CreateNode();
}
Exemplo n.º 8
0
static void MakeStaticRamp(SceneManager* const sceneMgr, OgreNewtonWorld* const world, const Vector3& location, int rampMaterialID)
{
    Vector3 blockBoxSize (20.0f, 0.25f, 40.0f);
    dNewtonCollisionBox shape (world, blockBoxSize.x, blockBoxSize.y, blockBoxSize.z, m_all);

    // create a texture for using with this material
    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().load("sand1b.jpg", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

    // make a material to use with this mesh
    MaterialPtr renderMaterial = MaterialManager::getSingleton().create("ramp", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    renderMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(true);
    renderMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("sand1b.jpg");
    renderMaterial->setAmbient(0.2f, 0.2f, 0.2f);

    OgreNewtonMesh boxMesh (&shape);
    boxMesh.Triangulate();
    int materialId = boxMesh.AddMaterial(renderMaterial);
    boxMesh.ApplyBoxMapping (materialId, materialId, materialId);

    // create a manual object for rendering
    ManualObject* const object = boxMesh.CreateEntity(MakeName ("ramp"));
    MeshPtr mesh (object->convertToMesh (MakeName ("ramp")));

    //Matrix4 matrix (Matrix4::IDENTITY);
    Matrix4 matrix (Quaternion (Degree(-30.0f), Vector3 (0.0f, 0.0f, 1.0f)));
    matrix.setTrans (Vector3 (location.x, location.y, location.z));

    Entity* const ent = sceneMgr->createEntity(MakeName ("ramp"), mesh);
    SceneNode* const node = CreateNode (sceneMgr, ent, matrix.getTrans(), matrix.extractQuaternion());

    shape.SetMaterialId (rampMaterialID);
    new OgreNewtonDynamicBody (world, 0.0f, &shape, node, matrix);

    delete object;
}
Exemplo n.º 9
0
void InsertNode(char *ptr, TNode *root)
{

	int len = strlen(ptr);
	bool insert = false;
	TNode *temp;
	for(int i = 0; i <len; i++)
	{
		insert = DoNeedNewEntry(ptr[i], root);
		if(insert)
		{
			temp = CreateNode();
			temp->data = ptr[i];
			if(i+1 == len)
				temp->terminate = true;

			root->ptr[ptr[i] - 'a'] = temp;
			root = temp;
		}
		else
		{
			root = root->ptr[ptr[i] - 'a'];
		}
	}

}
 //前两参数是关联的,后三参数是关联的!
 TreeNode *CreateNode(vector<int>& preorder, int root_index, vector<int>& inorder, int low, int high)
 {
     TreeNode* p_node = new TreeNode(preorder[root_index]);
     int index = FindRootIndexFromInorder(inorder, low, high, preorder[root_index]);
     int left_len = index - low;
     int right_len = high - index;
     if(left_len > 0)
     {
         p_node->left = CreateNode(preorder, root_index+1, inorder, low, index-1);
     }
     if(right_len > 0)
     {
         p_node->right = CreateNode(preorder, root_index+1+left_len, inorder, index+1, high);
     }
     return p_node;
 }
Exemplo n.º 11
0
    BOOL WriteString(
        LPCWSTR pszSection,
        LPCWSTR pszKey,
        LPCWSTR pszValue)
    {
        Node* pSection = GetNode(&m_pRoot, pszSection, (pszKey != NULL) ? CREATE_NODE : DELETE_NODE);
        if (pszKey == NULL)
            return TRUE;
        if (pSection == NULL)
            return FALSE;

        Node* pKey = GetNode(&pSection->pChild, pszKey, (pszValue != NULL) ? CREATE_NODE : DELETE_NODE);
        if (pszValue == NULL)
            return TRUE;
        if (pKey == NULL)
            return FALSE;

        Node* pValue = pKey->pChild;
        DWORD dwSize = sizeof(WCHAR) * wcslen(pszValue);
        if (pValue)
        {
            if (Equal(pValue, (LPCVOID)pszValue, dwSize))
                return TRUE;
            DestroyNode(pValue);
        }

        pKey->pChild = CreateNode((LPCVOID)pszValue, dwSize);
        if (pKey->pChild == NULL)
            return FALSE;

        return TRUE;
    }
Exemplo n.º 12
0
void BuildRandomTree(struct TreeNode *root,int nodeNum)
{
    srand(time(0));
    char branch[][2]= {"L","R"};
    char store[nodeNum][nodeNum];
    int mark[nodeNum][2];
    int Num[nodeNum];
    memset(store,0,sizeof(store));
    memset(mark,0,sizeof(mark));
    memset(Num,0,sizeof(Num));
    Num[0] = 1;
    int curNum = 1;
    for(curNum; curNum < nodeNum ; curNum++) {
        int num;
        do {
            num=rand()%nodeNum;
        } while(Num[num]);
        Num[num]=1;
        int LR=rand()%2;
        int randNode;
        do {
            randNode=rand()%curNum;
        } while(mark[randNode][LR]);
        mark[randNode][LR]=1;
        char newNode[nodeNum];
        memset(newNode,0,sizeof(newNode));
        strcpy(newNode,store[randNode]);
        strcat(newNode,branch[LR]);
        CreateNode(root,newNode,num);
        strcpy(store[curNum],newNode);
    }
}
Exemplo n.º 13
0
/* Function: Insert a new node with given data
 * Input:
 *    head: pointer to the start of linked list
 *    value: value to be stored in data field of new node
 *    N: position of node AFTER which new node should be inserted
 *       If N=0, then new node should be inserted in front (Special case)
 * Error: If invalid N, output error:
 *    ERROR: Node <N> does not exist 
 */
struct node* InsertAtN(struct node* head, int value, int N) {
    int i;
    struct node *tmp_node = head;
    struct node *cur_node = CreateNode();
    if(NULL == cur_node)
        return NULL;
    cur_node->next = NULL;
    cur_node->data = value;

    if(N == 0)
    {
        cur_node->next = head;
        head = cur_node;
    }

    for(i = 0; tmp_node != NULL && tmp_node->next != NULL && i < N-1; i++)
    {
        tmp_node = tmp_node->next;
    }

    if(i == N-1)
    {
        cur_node->next = tmp_node->next;
        tmp_node->next = cur_node;
    }
    else
    {
        printf("Node (N) doesn't exist");
        return NULL;
    }
	return head;
}
Exemplo n.º 14
0
void CParentNode::Load( QDataStream& ar, SelectNode& sn, std::vector<SelectNode>& bracketSn, int isLeftBrLoad )
{
	DeleteAllChild();

	// load
	CNode::Load( ar, sn, bracketSn, isLeftBrLoad );

	CNode *pNode, *pPrev = NULL;

	ar >> m_nNumLine;
	ar >> m_nNumColumn;

	qint32 count;
	ar >> count;
	for( qint32 i = 0; i < count; i++ )
	{
		qint32 type;
		ar >> type;

		qint32 is_ext_node = 0;
		ar >> is_ext_node;

		pNode = CreateNode( type, is_ext_node );
		pNode->Load( ar, sn, bracketSn, isLeftBrLoad );

		pNode->SetParent( this );
		pNode->SetPrev( pPrev );
		if( pPrev )
			pPrev->SetNext( pNode );
		pPrev = pNode;
		m_children.push_back( pNode );
	}
}
Exemplo n.º 15
0
btData * MiniNovaParser::Parse(string s) {
	if(s.find("request failed") == 0) {
		Log("FAILED TO CONNECT: ");
		return bd;
	}
	
	int count = 0;
	int pos = 0;
	int len = (int)s.length();
	pos = (int)s.find(" torrents", pos);
	if(pos < 0) {
		Log("Parse Error");
		//TRACE("Parser Error:\n");
		return bd;
	}
	len = (int)s.find("div id=\"footer\"", pos);
	TRACE("start: %d, len: %d\n", pos, len);
	while(pos < len && pos > 0) 
	{
		btData * newNode = CreateNode(s, &pos);
		if(bd == NULL) bd = newNode;
		else bd->AddNode(newNode);
		//TRACE("node:%s\n", newNode->ToString().c_str());
		count++;
	}

	char temp[16];
	itoa(count, temp, 10);
	char message[32];
	strcpy(message, "total count: ");
	strcat(message, temp);
	Log(message);

	return bd;
}
Exemplo n.º 16
0
LIST *txtGoKeyAndInsert(U32 textId, char *key, ...)
{
    va_list argument;
    LIST *txtList = CreateList(), *originList = NULL;
    NODE *node;

    va_start(argument, key);

    originList = txtGoKey(textId, key);

    for (node = LIST_HEAD(originList); NODE_SUCC(node); node = NODE_SUCC(node)) {
	U8 i;
	char originLine[256], txtLine[256];

	strcpy(originLine, NODE_NAME(node));
	strcpy(txtLine, NODE_NAME(node));

	for (i = 2; i < strlen(originLine); i++) {
	    if (originLine[i - 2] == '%') {
		sprintf(txtLine, originLine, va_arg(argument, U32));
		i = strlen(originLine) + 1;
	    }
	}

	CreateNode(txtList, 0, txtLine);
    }

    RemoveList(originList);

    return txtList;
}
status_t Converter::ConvertFreeMind2PDoc()
{
	BMessage	*document		= new BMessage();
	BMessage	*allNodes		= new BMessage();
	BMessage	*allConnections	= new BMessage();
	char		*xmlString;
	off_t		start,end;
	middel.Set(400,400,600,550);
	in->Seek(0,SEEK_SET);
	start = in->Position();
	in->Seek(0,SEEK_END);
	end = in->Position();
	in->Seek(0,SEEK_SET);
	size_t		size= end-start;
	xmlString=new char[size+1];
	in->Read(xmlString, size);
	TiXmlDocument	doc;
	doc.Parse(xmlString);
	delete xmlString;
	if (doc.Error())
		return B_ERROR;
	else
	{
		TiXmlNode*		node	= NULL;
		TiXmlElement*	element	= NULL;
		node = doc.FirstChild("map");
		node = node->FirstChild("node");
		element	= node->ToElement();
		CreateNode(allNodes, allConnections,element,0,0);
	}
	document->AddMessage("PDocument::allConnections",allConnections);
	document->AddMessage("PDocument::allNodes",allNodes);
	status_t err= document->Flatten(out);
}
Exemplo n.º 18
0
void AddElemntAtStart(List* list, char* name,SOCKET socket)
{
	Node *TemporaryNode;
	Node *node_new;
	do{
		node_new = CreateNode();
	} while (node_new == NULL);

	node_new->socket=socket;
	node_new->name = name;
	node_new->next = NULL;

	if (IsListEmpty(list))
	{
		list->firstNode = node_new;
		list->lastNode = node_new;
	}
	else 
	{
		TemporaryNode = list->firstNode;
		list->firstNode = node_new;
		list->firstNode->next = TemporaryNode;
	}
	list->size_of_list++;
}
Exemplo n.º 19
0
//          -----------------
//         \|/              |
//  1-------2-------3-------4-------5
//  |       |      /|\             /|\
//  --------+--------               |
//          -------------------------
void Test1()
{
    struct ComplexListNode* pNode1 = CreateNode(1);
    struct ComplexListNode* pNode2 = CreateNode(2);
    struct ComplexListNode* pNode3 = CreateNode(3);
    struct ComplexListNode* pNode4 = CreateNode(4);
    struct ComplexListNode* pNode5 = CreateNode(5);

    BuildNodes(pNode1, pNode2, pNode3);
    BuildNodes(pNode2, pNode3, pNode5);
    BuildNodes(pNode3, pNode4, NULL);
    BuildNodes(pNode4, pNode5, pNode2);

    Test("Test1", pNode1);
	DestroyList(pNode1);
}
Exemplo n.º 20
0
/* ************************************************************************
 *     Name: AddTail
 * Function: add a node to the tail of the list
 * Argument: PListNode pHead, void *data
 *   Return: int
 * ***********************************************************************/
int AddTail(PListNode pHead, void *data)
{
    PListNode node = NULL;
    PListNode newNode;
    
    node = pHead;
    if (node == NULL)
    {
        return FAIL;
    }
    else
    {
        while ((node->next) != NULL)   // find the tail
        {
            node = node->next;
        }
    }

    newNode = CreateNode();
    if (newNode == NULL)
    {
        return FAIL;
    }
    else
    {
        newNode->data = data;
        newNode->next = NULL;
        node->next = newNode;
    }
    return TRUE;
}
Exemplo n.º 21
0
int main( int argc, char **argv ) {
	
if( argc < 2) {
	printf("Usage %s n1 n2 n3...", argv[0]) ;
	return 0 ;
}
int i=1, p = 3 ; 
Node *n = CreateNode(p) ;
char f = 'y' ;
while(i != argc) {
	KeyFunct( n, atoi(argv[i++]), 'a' ) ;
}
printf("Starter Values Created\n");
while( f != 'q' ) {
	switch(f) {
		case 'a' :
		case 's' :
		case 'd' :
		case 'r' : {
			printf("Enter Key:") ;
			int k =0 ;
			scanf("%d", &k) ;
			Node *tn = n ;
			tn = KeyFunct(tn, k, f) ;
		}
		default : {
			printf("Commands (a)dd (r)eturn (s)earch (d)elete\n");
		} 
	}
	scanf("%c", &f) ;
}
return 0 ;
}
Exemplo n.º 22
0
void WnCourt::set_word(const gchar *orig_word, gchar **Word, gchar ***WordData)
{
	ClearScene();
	CurrentWord = orig_word;
	CreateWord(orig_word);
	if (Word == NULL)
		return;
	Push();
	std::string type;
	std::list<std::string> wordlist;
	std::string gloss;
	size_t i = 0;
	size_t j;
	do {
		j = 0;
		do {
			wordnet2result(orig_word, WordData[i][j], type, wordlist, gloss);
			CreateNode(gloss.c_str(), type.c_str());
			Push();
			for (std::list<std::string>::iterator it = wordlist.begin(); it != wordlist.end(); ++it) {
				CreateWord(it->c_str());
			}
			Pop();
			j++;
		} while (WordData[i][j]);
		i++;
	} while (Word[i]);
}
Exemplo n.º 23
0
// 只有一个结点
void Test4()
{
    ComplexListNode* pNode1 = CreateNode(1);
    BuildNodes(pNode1, nullptr, pNode1);

    Test("Test4", pNode1);
}
Exemplo n.º 24
0
void
inDOMView::ExpandNode(PRInt32 aRow)
{
  inDOMViewNode* node = nsnull;
  RowToNode(aRow, &node);

  nsCOMArray<nsIDOMNode> kids;
  GetChildNodesFor(node ? node->node : mRootNode,
                   kids);
  PRInt32 kidCount = kids.Count();

  nsTArray<inDOMViewNode*> list(kidCount);

  inDOMViewNode* newNode = nsnull;
  inDOMViewNode* prevNode = nsnull;

  for (PRInt32 i = 0; i < kidCount; ++i) {
    newNode = CreateNode(kids[i], node);
    list.AppendElement(newNode);

    if (prevNode)
      prevNode->next = newNode;
    newNode->previous = prevNode;
    prevNode = newNode;
  }

  InsertNodes(list, aRow+1);

  if (node)
    node->isOpen = PR_TRUE;
}
int32 USoundClassGraph::RecursivelyConstructChildNodes(USoundClassGraphNode* ParentNode, const TMap<USoundClass*, int32>& InChildCounts, bool bSelectNewNode/* = true*/)
{
	const int32 HorizontalSpacing = 400;
	const int32 VerticalSpacing = 100;

	USoundClass* ParentClass = ParentNode->SoundClass;
	int32 TotalChildSizeY = InChildCounts.FindChecked(ParentClass) * VerticalSpacing;
	int32 NodeStartY = ParentNode->NodePosY - (TotalChildSizeY * 0.5f) + (VerticalSpacing * 0.5f);
	int32 NodePosX = ParentNode->NodePosX + HorizontalSpacing;

	for (int32 ChildIndex = 0; ChildIndex < ParentClass->ChildClasses.Num(); ChildIndex++)
	{
		if (ParentClass->ChildClasses[ChildIndex])
		{
			const int32 ChildCount = InChildCounts.FindChecked(ParentClass->ChildClasses[ChildIndex]);
			int32 NodePosY = NodeStartY + (ChildCount * VerticalSpacing * 0.5f) - (VerticalSpacing * 0.5f);
			USoundClassGraphNode* ChildNode = CreateNode(ParentClass->ChildClasses[ChildIndex], NodePosX, NodePosY, bSelectNewNode);
			ParentNode->GetChildPin()->MakeLinkTo(ChildNode->GetParentPin());
			RecursivelyConstructChildNodes(ChildNode, InChildCounts);
			NodeStartY += ChildCount * VerticalSpacing;
		}
	}

	return TotalChildSizeY;
}
UEdGraphNode* FEdGraphSchemaAction_K2AssignDelegate::AssignDelegate(class UK2Node* NodeTemplate, class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode)
{
	UK2Node_AddDelegate* BindNode = NULL;
	if (UK2Node_AddDelegate* AddDelegateTemplate = Cast<UK2Node_AddDelegate>(NodeTemplate))
	{
		const FScopedTransaction Transaction( NSLOCTEXT("UnrealEd", "K2_AddNode", "Add Node") );
		ParentGraph->Modify();
		if (FromPin)
		{
			FromPin->Modify();
		}

		BindNode = Cast<UK2Node_AddDelegate>(CreateNode(ParentGraph, FromPin, Location, NodeTemplate, bSelectNewNode));
		UMulticastDelegateProperty* DelegateProperty = BindNode ? Cast<UMulticastDelegateProperty>(BindNode->GetProperty()) : NULL;
		if(DelegateProperty)
		{
			const FString FunctionName = FString::Printf(TEXT("%s_Event"), *DelegateProperty->GetName());
			UK2Node_CustomEvent* EventNode = UK2Node_CustomEvent::CreateFromFunction(
				FVector2D(Location.X - 150, Location.Y + 150), 
				ParentGraph, FunctionName, DelegateProperty->SignatureFunction, bSelectNewNode);
			if(EventNode)
			{
				const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
				UEdGraphPin* OutDelegatePin = EventNode->FindPinChecked(UK2Node_CustomEvent::DelegateOutputName);
				UEdGraphPin* InDelegatePin = BindNode->GetDelegatePin();
				K2Schema->TryCreateConnection(OutDelegatePin, InDelegatePin);
			}
		}

		UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForGraphChecked(ParentGraph);
		FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(Blueprint);
	}
	return BindNode;
}
Exemplo n.º 27
0
LIST *txtGoKey(U32 textId, const char *key)
{
    LIST *txtList = NULL;
    struct Text *txt = GetNthNode(txtBase->tc_Texts, textId);

    if (txt) {
	char *LastMark = NULL;

	/* MOD: 08-04-94 hg
         * if no key was given take the next one
	 * -> last position is temporarily saved in LastMark because
	 * txt->LastMark is modified in txtPrepare!
	 *
	 * Special case: no key, text never used !!
	 */
	if ((!key) && (txt->txt_LastMark))
	    LastMark = txt->txt_LastMark;

	txtPrepare(textId);

	/* Explanation for +1: LastMark points to the last key
	   -> without "+1" the same key would be returned */
	if (!key && LastMark)
	    txt->txt_LastMark = LastMark + 1;

	for (; *txt->txt_LastMark != TXT_CHAR_EOF; txt->txt_LastMark++) {
	    if (*txt->txt_LastMark == TXT_CHAR_MARK) {
		U8 found = 1;

		if (key) {
		    char mark[TXT_KEY_LENGTH];

		    strcpy(mark, txt->txt_LastMark + 1);

		    if (strcmp(key, mark) != 0)
			found = 0;
		}

		if (found) {
		    U8 i = 1;
		    char *line;

		    txtList = CreateList();

		    while ((line = txtGetLine(txt, i++)))
			CreateNode(txtList, 0, line);
		    break;
		}
	    }
	}

    }

    if (!txtList) {
	DebugMsg(ERR_ERROR, ERROR_MODULE_TXT, "NOT FOUND KEY '%s'", key);
    }

    return txtList;
}
Exemplo n.º 28
0
QuadTree::QuadTree() :
        m_node_pool(sizeof(QuadTreeNode), 500),
        m_mesh_pool(sizeof(QuadTreeMesh), 500)
{

    // Create the root node
    m_root_node = CreateNode();
}
Exemplo n.º 29
0
void initKruskalTree(int martix[100][100], int *able, int n, Node *(nodeadr[100]))
{
    int i, j, k;
    int minCost, minParent, minNode;
    int ableCount = n - 1;
    while (--ableCount)
    {
        minCost = 65535;
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                if (martix[i][j] < minCost && martix[i][j] > 0)
                {
                    minCost = martix[i][j];
                    minParent = i;
                    minNode = j;
                }
            }
        }

        if (nodeadr[minParent])
            nodeadr[minParent] = CreateNode(minParent, NULL, NULL, NULL, -1);

        if (nodeadr[minNode])
            nodeadr[minNode] = CreateNode(minNode, NULL, NULL, NULL, -1);

        if (!nodeadr[minParent]->left)
            nodeadr[minParent]->left = nodeadr[minNode];
        else if (!nodeadr[minParent]->right)
            nodeadr[minParent]->right = nodeadr[minNode];
        else if (!nodeadr[minParent]->parent)
            nodeadr[minParent]->parent = nodeadr[minNode];
        else
            printf("Something wrong");

        if (!nodeadr[minNode]->left)
            nodeadr[minNode]->left = nodeadr[minParent];
        else if (!nodeadr[minNode]->right)
            nodeadr[minNode]->right = nodeadr[minParent];
        else if (!nodeadr[minNode]->parent)
            nodeadr[minNode]->parent = nodeadr[minParent];
        else
            printf("Something wrong");
    }
}
Exemplo n.º 30
0
SConfig::SConfig()
{
    log.Log("SConfig:SConfig",COMMON,"初始化");
    CreateNode();
    ParseConfigFile(ConfigPath);
    log.Log("SConfig:SConfig",COMMON,"初始化完成");
    //display();
}