Exemplo n.º 1
0
void sort()
{
    char data[MAX_PATH_LEN];
    HeadNode* hn;
    Node* n;
    size_t idx;

    dll_init(&hn);

    while( fgets(data, MAX_PATH_LEN, stdin) != NULL )
    {
	n = dll_searchPredict(hn, data, &lessPredict);
	if( n == NULL )
	{
	    dll_insert(hn, hn->size, data);
	}
	else
	{
	    idx = dll_index(hn, &n);
	    dll_insert(hn, idx, data);
	}
    }

    //dll_printList(hn);
    for( idx=0; idx<hn->size; idx++ )
    {
	printf("%s", dll_at(hn, idx)->data);
    }

    dll_close(&hn);
}
Exemplo n.º 2
0
// Function to get the data of the cursor of a specified DlList_T
// Since there's no function to get the data of the cursor
void* getCursorData( DlList_T lst ) {

    // Get the data of the current location
    void* data = dll_next( lst );

    // If there is currently a cursor
    if( data != NULL ) {

        // Grab the index of that data
         int index = dll_index( lst, data );

        // Set the cursor back to that point
        dll_move_to( lst, index );
    }

    return data;
}
Exemplo n.º 3
0
// Function to get the index of the cursor of a specified DlList_T
// Since there's no function to get the index of the cursor
int getCursorIndex( DlList_T lst ) {

    // Get the data of the current location
    void* data = dll_next( lst );

    // There is no cursor currently
    if( data == NULL ) {
        return 0;
    }

    // Grab the index of that data
    int index = dll_index( lst, data );

    // Set the cursor back to that point
    dll_move_to( lst, index );

    return index;
}