我不明白avl树声明中的错误消息

时间:2017-04-03 03:32:05

标签: c++

我正在尝试编写AVL树,我收到了这个我不明白的错误,有人可以提供帮助。谢谢

source

enter image description here

public static Boolean cooldown(int id) {

    Calendar now = Calendar.getInstance();
    now.add(Calendar.SECOND, -secondsAgo);
    long timeAgo = now.getTimeInMillis();
    if ( cooldown.containsKey(id) ) {

        System.out.println(cooldown.get(id) + " | " + timeAgo);

        // Stored timestamp always older than timeAgo
        if ( cooldown.get(id) < timeAgo ) {

            cooldown.remove(id);

        } else {

            // This code should be executed, as I am running the function one after another from same UUID not even a second or two apart.
            return false;

        }

    }

    now = Calendar.getInstance();
    cooldown.put(id, now.getTimeInMillis());

    return true;

}

1 个答案:

答案 0 :(得分:1)

尝试使用这些更改:

template<class KeyType, class ItemType>
class AVL
{
 protected:
 // Unnecessary -> template<class KeyType, class ItemType>
 class AVLNode
 {
  public:
     AVLNode(KeyType key, ItemType item) : m_Balance(0), m_Depth(0),
                                           m_Key(key), m_Data(item),
                                           m_pLeft(0), m_pRight(0)
  { }

  private:
     int m_Balance;  // Missing from the ctor declaration
     int m_Depth;  // Missing from the ctor declaration
     KeyType m_Key;
     ItemType m_Data;

     AVLNode<KeyType, ItemType>*  m_pLeft;  // Change here
     AVLNode<KeyType, ItemType>*  m_pRight; // Change here
  };

  AVLNode<KeyType, ItemType>* m_pRoot;
  public:
  AVL() : m_pRoot(0) { }
  ~AVL() { }
};