dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Help in coming up with the data structure

  1. #1
    Join Date
    May 2015
    Posts
    220

    Help in coming up with the data structure

    Hello,

    Happy new year to all. Thanks a lot for the help during the last year , helped me a lot

    I have the following data structure:

    typedef MultiTechCellConstPtrList::iterator MultiTechCellConstPtrListIter;
    typedef std::map<const MultiTechNode*, MultiTechCellConstPtrList> MultiTechNodePtr2CellListMap;
    typedef MultiTechNodePtr2CellListMap::iterator MultiTechNodePtr2CellListMapIter;

    Code:
    void CACellIdentityPlanner::PopulateMultiTechNodePtr2CellListMap()
    {
    	ILogicalLayerManager&	rLogLayManager	= DataManager::GetInstance().GetLogicalLayer();
    	UserGroupManager&		rUserGrpManager	= UserGroupInstance::instance().GetManager();
    
    	ASSERT_ONCE( m_MultiTechNodePtr2CellListMap.size() == 0 );
    
    	if ( m_netType == TGNETWORK_LTE )
    	{
    		const safemap<int, LPLTECELL>& rCellList = m_rCACellIdPlannerData.GetLTECellList();
    		m_pProgressDlg->SetCurrentRangeMax((ULONG)rCellList.size()-1);
    
    		for (auto& mapObj : rCellList)
    		{
    			const int iCellKey = mapObj.first;
    			const MultiTechCell* pCell = dynamic_cast<const MultiTechCell*>( rLogLayManager.Find(OT_MULTI_TECH_CELL, iCellKey) );
    
    			if ( !rUserGrpManager.CanModifyObject(*pCell) ) continue;
    			if ( pCell->GetActiveTechnologyMode() == m_netType )
    			{
    				const auto* pNode = static_cast<const MultiTechNode*>(pCell->GetParent());
    				MultiTechNodePtr2CellListMapIter iterNode = m_MultiTechNodePtr2CellListMap.find(pNode);
    
    				if ( iterNode == m_MultiTechNodePtr2CellListMap.end() )				// If not seen the node before ...
    				{
    					MultiTechCellConstPtrList rList;
    					rList.push_back(pCell);
    					m_MultiTechNodePtr2CellListMap.insert(make_pair(pNode, rList));	// ... add node to map, and start a new list of it's child cells
    				}
    				else
    				{
    					MultiTechCellConstPtrList& rList = iterNode->second;			// .. else update the list of child cells for the node
    					rList.push_back(pCell);
    				}
    			}
    			m_pProgressDlg->IncrementCurrentProgress();
    		}
    	}
    	else if ( m_netType == TGNETWORK_5G )
    	{
    		const safemap<int, LP5GCELL>& rCellList = m_rCACellIdPlannerData.Get5GCellList();
    		m_pProgressDlg->SetCurrentRangeMax((ULONG)rCellList.size()-1);
    
    		for (auto& mapObj : rCellList)
    		{
    			const int iCellKey = mapObj.first;
    			const MultiTechCell* pCell = dynamic_cast<const MultiTechCell*>( rLogLayManager.Find(OT_MULTI_TECH_CELL, iCellKey) );
    
    			if ( !rUserGrpManager.CanModifyObject(*pCell) ) continue;
    			if ( pCell->GetActiveTechnologyMode() == m_netType )
    			{
    				const auto* pNode = static_cast<const MultiTechNode*>(pCell->GetParent());
    				MultiTechNodePtr2CellListMapIter iterNode = m_MultiTechNodePtr2CellListMap.find(pNode);
    
    				if ( iterNode == m_MultiTechNodePtr2CellListMap.end() )				// If not seen the node before ...
    				{
    					MultiTechCellConstPtrList rList;
    					rList.push_back(pCell);
    					m_MultiTechNodePtr2CellListMap.insert(make_pair(pNode, rList));	// ... add node to map, and start a new list of it's child cells
    				}
    				else
    				{
    					MultiTechCellConstPtrList& rList = iterNode->second;			// .. else update the list of child cells for the node
    					rList.push_back(pCell);
    				}
    			}
    			m_pProgressDlg->IncrementCurrentProgress();
    		}
    	}
    	else
    	{
    		ASSERT_ONCE(0);	// Unknown network type
    	}
    }
    But now i want to add a new functionality, where I want to group the 5g cells and LTE cells.
    i.e Under Multitechnode, there can be 5g cells and LTE cells. And I want to compare each LTE cell with 5g cell for a property and if that matches, I want to create a new list which lists those cells that match.

    Which is the best data structure for this purpose.

    I was thinking to store the LTE and 5g cells separately in the input map.
    Code:
    // New typedefs to store the LTE and 5g cells separately within the MultiTechNode
    typedef std::pair<MultiTechCellConstPtrList, MultiTechCellConstPtrList>     Lte5gCellListMap;
    typedef std::map<const MultiTechNode*, Lte5gCellListMap>		            MultiTechNodePtr2Lte5gCellListMap;
    typedef MultiTechNodePtr2Lte5gCellListMap::iterator							MultiTechNodePtr2Lte5gCellListMapIter;
    So i populate the input map with separate LTE and 5gcells under one MuTechnode. And then, compare the LTE cells list with 5g and put the list into separate output map.

    Could you let me know if this is ok ? Or do you suggest any alternatives, improvements ?

    Thanks a lot again

    Pdk

  2. #2
    Join Date
    May 2015
    Posts
    220

    Re: Help in coming up with the data structure

    I think instead of pair value, i guess, i can use struct as map value. And struct can have two lists, one for lte and one for 5g ?

    typedef struct {
    list<MultiTechCell> ltecelllist;
    list<MultiTechCell> 5gCelllist;
    } lte5gCellList;
    typedef std::map<const MultiTechNode*, lte5gCellList> MultiTechNodePtr2Lte5gCellListMap;
    typedef MultiTechNodePtr2Lte5gCellListMap::iterator MultiTechNodePtr2Lte5gCellListMapIter;

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)