aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java/com/libmailcore/IndexSet.java
blob: 76506bca8b8356aa26c61d5f0bb4a61513f58f65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.libmailcore;

import java.util.List;

/** Unordered set of indexes. */
public class IndexSet extends NativeObject {
    /** Constructor. */
    public IndexSet() {
        setupNative();
    }
    
    /** Returns an empty set of indexes. */
    public static native IndexSet indexSet();
    /** Returns a set of indexes with a range. */
    public static native IndexSet indexSetWithRange(Range range);
    /** Returns a set of indexes with a single value. */
    public static native IndexSet indexSetWithIndex(long idx);
    
    /** Returns the number of indexes. */
    public native int count();
    /** Adds an index. */
    public native void addIndex(long idx);
    /** Removes an index. */
    public native void removeIndex(long idx);
    /** Returns whether the set of indexes holds the given value. */
    public native boolean containsIndex(long idx);
    
    /** Adds a range of values. */
    public native void addRange(Range range);
    /** Remove a range of values. */
    public native void removeRange(Range range);
    /** Intersects with the given range. The set is modified to contains only indexes that
        are part of the given range. */
    public native void intersectsRange(Range range);
    
    /** Adds indexes of the given set of indexes. */
    public native void addIndexSet(IndexSet indexSet);
    /** Removes indexes of the given set. */
    public native void removeIndexSet(IndexSet indexSet);
    /** Intersects with the given set of indexes. */
    public native void intersectsIndexSet(IndexSet indexSet);
    
    /** Returns all the ranges that the set contains. */
    public native List<Range> allRanges();
    /** Returns the number of ranges that the set contains. */
    public native int rangesCount();
    /** Empties the set. */
    public native void removeAllIndexes();
    
    private native void setupNative();

    private static final long serialVersionUID = 1L;
}