Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / lang / csharp / src / HashCursor.cs
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2009, 2012 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 using System;
8 using System.Collections.Generic;
9 using System.Text;
10 using BerkeleyDB.Internal;
11
12 namespace BerkeleyDB {
13     /// <summary>
14     /// A class for traversing the records of a <see cref="HashDatabase"/>
15     /// </summary>
16     public class HashCursor : Cursor {
17         internal HashCursor(DBC dbc, uint pagesize)
18             : base(dbc, DatabaseType.HASH, pagesize) { }
19         internal HashCursor(DBC dbc, uint pagesize, CachePriority p)
20             : base(dbc, DatabaseType.HASH, pagesize, p) { }
21
22         /// <summary>
23         /// Create a new cursor that uses the same transaction and locker ID as
24         /// the original cursor.
25         /// </summary>
26         /// <remarks>
27         /// This is useful when an application is using locking and requires two
28         /// or more cursors in the same thread of control.
29         /// </remarks>
30         /// <param name="keepPosition">
31         /// If true, the newly created cursor is initialized to refer to the
32         /// same position in the database as the original cursor (if any) and
33         /// hold the same locks (if any). If false, or the original cursor does
34         /// not hold a database position and locks, the created cursor is
35         /// uninitialized and will behave like a cursor newly created by
36         /// <see cref="HashDatabase.Cursor"/>.</param>
37         /// <returns>A newly created cursor</returns>
38         public new HashCursor Duplicate(bool keepPosition) {
39             return new HashCursor(
40                 dbc.dup(keepPosition ? DbConstants.DB_POSITION : 0), pgsz);
41         }
42         /// <summary>
43         /// Insert the data element as a duplicate element of the key to which
44         /// the cursor refers.
45         /// </summary>
46         /// <param name="data">The data element to insert</param>
47         /// <param name="loc">
48         /// Specify whether to insert the data item immediately before or
49         /// immediately after the cursor's current position.
50         /// </param>
51         public new void Insert(DatabaseEntry data, InsertLocation loc) {
52             base.Insert(data, loc);
53         }
54         /// <summary>
55         /// Insert the specified key/data pair into the database, unless a
56         /// key/data pair comparing equally to it already exists in the
57         /// database.
58         /// </summary>
59         /// <param name="pair">The key/data pair to be inserted</param>
60         /// <exception cref="KeyExistException">
61         /// Thrown if a matching key/data pair already exists in the database.
62         /// </exception>
63         public new void AddUnique(
64             KeyValuePair<DatabaseEntry, DatabaseEntry> pair) {
65             base.AddUnique(pair);
66         }
67         /// <summary>
68         /// Insert the specified key/data pair into the database.
69         /// </summary>
70         /// <param name="pair">The key/data pair to be inserted</param>
71         /// <param name="loc">
72         /// If the key already exists in the database and no duplicate sort
73         /// function has been specified, specify whether the inserted data item
74         /// is added as the first or the last of the data items for that key. 
75         /// </param>
76         public new void Add(KeyValuePair<DatabaseEntry, DatabaseEntry> pair,
77             InsertLocation loc) {
78             base.Add(pair, loc);
79         }
80     }
81 }