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

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
主站蜘蛛池模板: 阿克| 贵德县| 桐乡市| 乌什县| 邵阳市| 新平| 鄂伦春自治旗| 南投县| 汶上县| 岫岩| 深州市| 长宁区| 灵石县| 铅山县| 定边县| 宜宾县| 伽师县| 大姚县| 镇原县| 镇宁| 明星| 平阴县| 山阴县| 左贡县| 沙田区| 耿马| 天峻县| 黑河市| 靖远县| 丽江市| 东平县| 盐池县| 公安县| 壶关县| 台湾省| 凤山县| 虎林市| 孝感市| 清原| 政和县| 江油市|