コード例 #1
0
ファイル: node.cpp プロジェクト: davidluca3000/vscp_software
bool CDoubleLinkedList::addNode( CNodeObject * pObject )
{
  int nsearchResult = 0;
  CNode * pNode = m_pHead;
    
  if ( m_nSort == SORT_NONE ) {
    // No sorting just add as last element
    addNodeTail( pObject );
    
    return true;
  }
  
  if ( ( m_nSort == SORT_STRING ) && ( NULL == pObject->m_pstrSortKey )  ) {
    return false;
  }
  
  if ( ( m_nSort == SORT_NUMERIC ) && ( NULL == pObject->m_pKey )  ) {
    return false;
  }
  
  if ( NULL != pNode ) {
    
    while (pNode != NULL ) {
      if ( ( m_nSort == SORT_STRING ) && ( NULL != pObject->m_pstrSortKey ) ) {
    nsearchResult =  strcmp( pNode->getObject()->m_pstrSortKey,
                 pObject->m_pstrSortKey );
      }
      else if ( ( m_nSort == SORT_NUMERIC ) ) {
    if ( *pObject->m_pKey == *pNode->getObject()->m_pKey ) {
      nsearchResult = 0;
    }
    else if ( *pObject->m_pKey > *pNode->getObject()->m_pKey ) {
      nsearchResult = 2;
    }
    else {
      nsearchResult = -1;
    }
      }
      
      if ( 0 == nsearchResult ) {
    // Entry already in table - Not allowed
    return false;
      }
      else if ( nsearchResult > 0 ) {
    // Add before current item
    addNodeBefore( pNode, pObject );
    return true;
      }
        
      pNode = pNode->getNextNode();
    }
  }
  else {	
    // Add to tail - last id
    addNodeTail( pObject );
  }
  
  return true;
}
コード例 #2
0
ファイル: node.cpp プロジェクト: davidluca3000/vscp_software
CNode * CDoubleLinkedList::findNode( char * strID )
{
  CNode * pRV = NULL;
  CNode * pNode = m_pHead;
    
  while (pNode != NULL ) {
    if ( 0 == strcmp( strID, pNode->getObject()->m_pstrSortKey ) ) {
      pRV = pNode;	
      break;
    }
    
    pNode = pNode->getNextNode();
  }
  
  return pRV;
}
コード例 #3
0
ファイル: node.cpp プロジェクト: davidluca3000/vscp_software
CNode * CDoubleLinkedList::findNode( unsigned long  nID )
{
  CNode * pRV = NULL;
  CNode * pNode = m_pHead;
    
  while (pNode != NULL ) {
    if ( nID == *pNode->getObject()->m_pKey ) {
      pRV = pNode;		
      break;
    }
    
    
    pNode = pNode->getNextNode();
  }
  
  return pRV;
}