dns: add missing exports.BADNAME
[platform/upstream/nodejs.git] / lib / _linklist.js
1 'use strict';
2
3 function init(list) {
4   list._idleNext = list;
5   list._idlePrev = list;
6 }
7 exports.init = init;
8
9
10 // show the most idle item
11 function peek(list) {
12   if (list._idlePrev == list) return null;
13   return list._idlePrev;
14 }
15 exports.peek = peek;
16
17
18 // remove the most idle item from the list
19 function shift(list) {
20   var first = list._idlePrev;
21   remove(first);
22   return first;
23 }
24 exports.shift = shift;
25
26
27 // remove a item from its list
28 function remove(item) {
29   if (item._idleNext) {
30     item._idleNext._idlePrev = item._idlePrev;
31   }
32
33   if (item._idlePrev) {
34     item._idlePrev._idleNext = item._idleNext;
35   }
36
37   item._idleNext = null;
38   item._idlePrev = null;
39 }
40 exports.remove = remove;
41
42
43 // remove a item from its list and place at the end.
44 function append(list, item) {
45   remove(item);
46   item._idleNext = list._idleNext;
47   list._idleNext._idlePrev = item;
48   item._idlePrev = list;
49   list._idleNext = item;
50 }
51 exports.append = append;
52
53
54 function isEmpty(list) {
55   return list._idleNext === list;
56 }
57 exports.isEmpty = isEmpty;