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

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
主站蜘蛛池模板: 东丽区| 松潘县| 宁阳县| 读书| 新邵县| 太仓市| 鹤岗市| 西乌| 从化市| 筠连县| 宿松县| 葫芦岛市| 凉山| 新河县| 偏关县| 辽源市| 车险| 云霄县| 利辛县| 东宁县| 桃园县| 新龙县| 龙胜| 翁源县| 上犹县| 保靖县| 宜丰县| 阿鲁科尔沁旗| 云阳县| 扎兰屯市| 慈利县| 达拉特旗| 绵竹市| 常山县| 江阴市| 阿鲁科尔沁旗| 海盐县| 三穗县| 五原县| 昌乐县| 游戏|