13514
|
1 /*
|
|
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This
|
|
3 * code is released under a tri EPL/GPL/LGPL license. You can use it,
|
|
4 * redistribute it and/or modify it under the terms of the:
|
|
5 *
|
|
6 * Eclipse Public License version 1.0
|
|
7 * GNU General Public License version 2
|
|
8 * GNU Lesser General Public License version 2.1
|
|
9 */
|
|
10 package com.oracle.truffle.ruby.runtime.core.array;
|
|
11
|
|
12 /**
|
|
13 * Interface to various ways to store values in arrays.
|
|
14 */
|
|
15 public interface ArrayStore {
|
|
16
|
|
17 /**
|
|
18 * Get the size of the store.
|
|
19 */
|
|
20 int size();
|
|
21
|
|
22 /**
|
|
23 * Get a value from the array using a normalized index.
|
|
24 */
|
|
25 Object get(int normalisedIndex);
|
|
26
|
|
27 /**
|
|
28 * Get a range of values from an array store.
|
|
29 */
|
|
30 ArrayStore getRange(int normalisedBegin, int truncatedNormalisedExclusiveEnd);
|
|
31
|
|
32 /**
|
|
33 * Set a value at an index, or throw {@link GeneraliseArrayStoreException} if that's not
|
|
34 * possible.
|
|
35 */
|
|
36 void set(int normalisedIndex, Object value) throws GeneraliseArrayStoreException;
|
|
37
|
|
38 /**
|
|
39 * Set a range to be a single value, or throw {@link GeneraliseArrayStoreException} if that's
|
|
40 * not possible.
|
|
41 */
|
|
42 void setRangeSingle(int normalisedBegin, int truncatedNormalisedExclusiveEnd, Object value) throws GeneraliseArrayStoreException;
|
|
43
|
|
44 /**
|
|
45 * Set a range to be a copied from another array, or throw {@link GeneraliseArrayStoreException}
|
|
46 * if that's not possible.
|
|
47 */
|
|
48 void setRangeArray(int normalisedBegin, int normalisedExclusiveEnd, ArrayStore other) throws GeneraliseArrayStoreException;
|
|
49
|
|
50 /**
|
|
51 * Insert a value at an index, or throw {@link GeneraliseArrayStoreException} if that's not
|
|
52 * possible.
|
|
53 */
|
|
54 void insert(int normalisedIndex, Object value) throws GeneraliseArrayStoreException;
|
|
55
|
|
56 /**
|
|
57 * Push a value onto the end, or throw {@link GeneraliseArrayStoreException} if that's not
|
|
58 * possible.
|
|
59 */
|
|
60 void push(Object value) throws GeneraliseArrayStoreException;
|
|
61
|
|
62 /**
|
|
63 * Delete a value at an index, returning the value.
|
|
64 */
|
|
65 Object deleteAt(int normalisedIndex);
|
|
66
|
|
67 /**
|
|
68 * Does a store contain a value?
|
|
69 */
|
|
70 boolean contains(Object value);
|
|
71
|
|
72 /**
|
|
73 * Duplicate the store.
|
|
74 */
|
|
75 ArrayStore dup();
|
|
76
|
|
77 /**
|
|
78 * Duplicate the store, in a format which can store an object.
|
|
79 */
|
|
80 ArrayStore generalizeFor(Object type);
|
|
81
|
|
82 /**
|
|
83 * Get the type of value stored.
|
|
84 */
|
|
85 Object getIndicativeValue();
|
|
86
|
|
87 /**
|
|
88 * Get the contents of the store as a new array.
|
|
89 */
|
|
90 Object[] toObjectArray();
|
|
91
|
|
92 /**
|
|
93 * Does one store equal another.
|
|
94 */
|
|
95 boolean equals(ArrayStore other);
|
|
96
|
|
97 }
|