/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/DCLLItem.java

# · Java · 105 lines · 37 code · 11 blank · 57 comment · 0 complexity · 11424419e5d8b612f5702e6c5c8ea7cd MD5 · raw file

  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.ql.exec.persistence;
  19. /**
  20. * Doubly circular linked list item.
  21. */
  22. public class DCLLItem {
  23. DCLLItem prev;
  24. DCLLItem next;
  25. DCLLItem() {
  26. prev = next = this;
  27. }
  28. /**
  29. * Get the next item.
  30. *
  31. * @return the next item.
  32. */
  33. public DCLLItem getNext() {
  34. return next;
  35. }
  36. /**
  37. * Get the previous item.
  38. *
  39. * @return the previous item.
  40. */
  41. public DCLLItem getPrev() {
  42. return prev;
  43. }
  44. /**
  45. * Set the next item as itm.
  46. *
  47. * @param itm
  48. * the item to be set as next.
  49. */
  50. public void setNext(DCLLItem itm) {
  51. next = itm;
  52. }
  53. /**
  54. * Set the previous item as itm.
  55. *
  56. * @param itm
  57. * the item to be set as previous.
  58. */
  59. public void setPrev(DCLLItem itm) {
  60. prev = itm;
  61. }
  62. /**
  63. * Remove the current item from the doubly circular linked list.
  64. */
  65. public void remove() {
  66. next.prev = prev;
  67. prev.next = next;
  68. prev = next = null;
  69. }
  70. /**
  71. * Add v as the previous of the current list item.
  72. *
  73. * @param v
  74. * inserted item.
  75. */
  76. public void insertBefore(DCLLItem v) {
  77. prev.next = v;
  78. v.prev = prev;
  79. v.next = this;
  80. prev = v;
  81. }
  82. /**
  83. * Add v as the previous of the current list item.
  84. *
  85. * @param v
  86. * inserted item.
  87. */
  88. public void insertAfter(DCLLItem v) {
  89. next.prev = v;
  90. v.next = next;
  91. v.prev = this;
  92. next = v;
  93. }
  94. }