官术网_书友最值得收藏!

Implementing APIs

Implementing an API is never as easy as it seems, as discussed earlier. When making generic classes, we can never predict what kinds of a situation our queue is going to be used in. With that in mind, let's create a very generic API for our queue and expand it in future as we see fit. Some of the most common operations that we can add to the queue are as follows:

  •  add(): Pushes an item to the back of the queue
  •  remove(): Removes an item from the start of the queue
  •  peek(): Shows the last item added to the queue
  •  front(): Returns the item at the front of the queue
  •  clear(): Empties the queue
  •  size(): Gets the current size of the queue
主站蜘蛛池模板: 手游| 富锦市| 格尔木市| 高陵县| 丽江市| 云霄县| 读书| 收藏| 广宁县| 衡山县| 宣城市| 临泽县| 岳阳县| 德兴市| 克什克腾旗| 北碚区| 乳山市| 荔波县| 萝北县| 西畴县| 敖汉旗| 名山县| 建宁县| 鄂尔多斯市| 张家川| 烟台市| 海城市| 余江县| 从江县| 南木林县| 宿州市| 平陆县| 游戏| 蒙城县| 新和县| 星子县| 阿克| 上虞市| 牡丹江市| 平远县| 乐至县|