Пример #1
0
void TestList()
{
    T_NODE headNode = {NULL, NULL};
   
    Insert2List(&headNode, "first", "firstcontent");
    Insert2List(&headNode, "second", "secondcontent");
   
    PrintList(&headNode);
   
    T_XML_NODE xmlArr[] = {
        {"second", "secondcontent"},
        {"first", "firstcontent"},
        {NULL, NULL},
    };
    AssertList(&headNode, xmlArr);
    
    FreeList(&headNode);
}
void Insert2List(V VertexNode, int VertexID)
{
    if (!VertexNode->Next || VertexNode->Next->ID >= VertexID)
    {
        V TempVertex = (V)malloc(sizeof(struct Vertex));
        TempVertex->ID = VertexID;
        TempVertex->Next = VertexNode->Next ? VertexNode->Next : NULL;
        VertexNode->Next = TempVertex;
    }
    else
    {
        Insert2List(VertexNode->Next, VertexID);
    }
}
Пример #3
0
// current is state starttag, jump2Content event is triggered, now do some action
E_RETURN_TYPE EventHandler_StateEndTag_Jump2Null(char cCurrentChar, PT_XML_PARSE_STATE_MACHINE ptStateMachine, PT_NODE ptHead)
{
MyPrintf("EventHandler_StateEndTag_Jump2Null enter");
    // discard current char, compare starttag with endtag
    // if starttag equals to endtag, add tagName-content into list
    if ( !strcmp(ptStateMachine->tStartTag.szStr, ptStateMachine->tEndTag.szStr) )
    {
        Insert2List(ptHead, ptStateMachine->tStartTag.szStr, ptStateMachine->tContent.szStr);
    }
    else
    {
        MyPrintf("start tag(%s) do not match end tag(%s), ", ptStateMachine->tStartTag.szStr, ptStateMachine->tEndTag.szStr);
    }

    FreeXMLParseStateMachine(ptStateMachine);
    InitXMLParseStateMachine(ptStateMachine);
}
void SetEdge(V *AdjacencyList, int VertexID1, int VertexID2)
{
    Insert2List(AdjacencyList[VertexID1], VertexID2);
    Insert2List(AdjacencyList[VertexID2], VertexID1);
}