Exemple #1
0
  void avltest<T>::MainMenu(AVLtree<T> & b, menu_choice menu_item)  {
	 T v;
	 switch (menu_item)  {
		case add:
			cout <<"\nEnter value of item to be added! : ";
			cin >> v;
			cout <<"\n";
			insert(b,v);
			break;
		case del:
			cout <<"\nEnter key of item to be deleted! : ";
			cin >> v;
			cout <<"\n";
			remove(b,v);
			break;
		case showoff:
			ShowAll(b);
			cout <<"\n\n";
			break;
		case query:
			cout <<"\nEnter key to be searched for! : ";
			cin >> v;
			cout <<"\n";
			if (IsFound(b,v))
			  cout <<"\nThe key "<< v <<" has been found! \n";
			else
			  cout <<"\nThe key "<< v <<" is not in the tree! \n";
			break;
		case quit:
			cout <<"Test ended.  Final traversal of the tree:\n";
			break;
		default:
			cout <<"\nOperation not supported.  Please select again! \n";
	 }
  }
 static
 bool IsBlackKey(Int32 note_number) { return IsFound(note_number % 12, kBlackKeyIndices); }
 static
 bool IsWhiteKey(Int32 note_number) { return IsFound(note_number % 12, kWhiteKeyIndices); }