Example #1
0
TEST_F(ChannelInternalStatePriorityTests, FindInsertionPointMiddlePriority) {
  // New sound's priority is...
  // ...between highest and second highest.
  EXPECT_EQ(channels_[0].priority_node(), FindInsertionPoint(&list_, 1.5f));
  // ...lower than a sound with the same priority as the previous sound.
  EXPECT_EQ(channels_[2].priority_node(), FindInsertionPoint(&list_, 0.5));
}
Example #2
0
TEST_F(ChannelInternalStatePriorityTests, FindInsertionPointWithEqualPriority) {
  // New sound's priority is...
  // ...equal to highest priority.
  EXPECT_EQ(channels_[0].priority_node(), FindInsertionPoint(&list_, 2.0f));
  // ...equal to a sound with the same priority as the previous sound.
  EXPECT_EQ(channels_[2].priority_node(), FindInsertionPoint(&list_, 1.0f));
  // ...equal to the lowest priority.
  EXPECT_EQ(channels_[3].priority_node(), FindInsertionPoint(&list_, 0));
}
Example #3
0
void CBinaryTree::DeleteNode(int N)
{
 CNode *pNode=pRoot,*pParent=NULL;

 pNode=LocateNode(N,pRoot);
 pParent=LocateParent(N,pRoot);

 if(pNode!=NULL)
 {
  if(pParent==NULL)
  {
   pRoot=pNode->pRight;
   pParent=FindInsertionPoint(pNode->pLeft->GetData(),pNode->pRight);
   pParent->pLeft=pNode->pLeft;
  }
  else
  {
   if(pParent->pLeft==pNode)
   {
    if(pNode->pRight==NULL && pNode->pLeft!=NULL)
     pParent->pLeft=pNode->pLeft;
    if(pNode->pRight!=NULL && pNode->pLeft==NULL)
     pParent->pLeft=pNode->pRight;
    if(pNode->pRight!=NULL && pNode->pLeft!=NULL)
    {
     pParent->pLeft=pNode->pRight;
     pParent=FindInsertionPoint(pNode->pLeft->GetData(),pNode->pRight);
     if(pParent->GetData()>N)
      pParent->pLeft=pNode->pLeft;
     else
      pParent->pRight=pNode->pLeft;
    }
   }
   else
   {
    if(pNode->pRight==NULL && pNode->pLeft!=NULL)
     pParent->pRight=pNode->pLeft;
    if(pNode->pRight!=NULL && pNode->pLeft==NULL)
     pParent->pRight=pNode->pRight;
    if(pNode->pRight!=NULL && pNode->pLeft!=NULL)
    {
     pParent->pLeft=pNode->pRight;
     pParent=FindInsertionPoint(pNode->pLeft->GetData(),pNode->pRight);
     if(pParent->GetData()<N)
      pParent->pLeft=pNode->pLeft;
     else
      pParent->pRight=pNode->pLeft;
    }
   }
  }
  delete pNode;
 }
 else
  cout<<endl<<"Node not found!";
}
Example #4
0
TEST_F(ChannelInternalStatePriorityTests, FindInsertionPointLowest) {
  // New sound's priority is less than the lowest prioity.
  EXPECT_EQ(channels_[3].priority_node(), FindInsertionPoint(&list_, -1.0f));
}
Example #5
0
TEST_F(ChannelInternalStatePriorityTests, FindInsertionPointAtHead) {
  // New sound's priority is greater than highest priority.
  EXPECT_EQ(list_.GetTerminator(), FindInsertionPoint(&list_, 2.5f));
}