View Javadoc
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,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.directory.mavibot.btree;
21  
22  
23  /**
24   * A holder to store the Values
25   * 
26   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
27   * @param <V> The value type
28   */
29  /* no qualifier */interface ValueHolder<V> extends Cloneable
30  {
31      /**
32       * Tells if a value is contained in this ValueHolder
33       * 
34       * @param checkedValue The added to check
35       */
36      boolean contains( V checkedValue );
37  
38  
39      /**
40       * @return the number of stored values
41       */
42      int size();
43  
44  
45      /**
46       * @return a cursor on top of the values
47       */
48      ValueCursor<V> getCursor();
49  
50  
51      /**
52       * @return true if we store the values in a sub btree
53       */
54      boolean isSubBtree();
55  
56  
57      /**
58       * Add a new value in the ValueHolder
59       * 
60       * @param newValue The added value
61       */
62      void add( V newValue );
63  
64  
65      /**
66       * Remove a value from the ValueHolder
67       * 
68       * @param removedValue The value to remove
69       */
70      V remove( V removedValue );
71  
72      
73      /**
74       * Replaces the single value present in the array.
75       * 
76       * This is only applicable for B-Trees that don't
77       * support duplicate values.
78       *
79       * @param newValue the new value
80       * @return the value that was replaced
81       */
82      V replaceValueArray( V newValue );
83      
84  
85      /**
86       * Create a clone of this instance
87       * 
88       * @return a new instance of a ValueHolder
89       * @throws CloneNotSupportedException If we can't clone this instance
90       */
91      ValueHolder<V> clone() throws CloneNotSupportedException;
92  }