
上QQ阅读APP看书,第一时间看更新
4-2 数据读取dequeue
在队列读取数据后,会将此数据从队列中移除,我们也可以称此为取出数据,下列是依序读取队列数据的步骤说明:
步骤1:
读取队列,可以得到Grape,同时Grape从队列中被移除。

步骤2:
读取队列,可以得到Mango,同时Mango从队列中被移除。

步骤3:
读取队列,可以得到Apple,同时Apple从队列中被移除。

这种数据结构的特色是必须读取先进入的数据,无法读取中间数据。
在队列读取数据后,会将此数据从队列中移除,我们也可以称此为取出数据,下列是依序读取队列数据的步骤说明:
步骤1:
读取队列,可以得到Grape,同时Grape从队列中被移除。
步骤2:
读取队列,可以得到Mango,同时Mango从队列中被移除。
步骤3:
读取队列,可以得到Apple,同时Apple从队列中被移除。
这种数据结构的特色是必须读取先进入的数据,无法读取中间数据。