Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.util

public Class FixedSizeList

extends MutabilityControl
implements ToHuman
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.util.ToHuman
Known Direct Subclasses
org.droidparts.dexmaker.dx.util.LabeledList, org.droidparts.dexmaker.dx.dex.code.CatchHandlerList, org.droidparts.dexmaker.dx.dex.code.CatchTable, org.droidparts.dexmaker.dx.dex.code.DalvInsnList, org.droidparts.dexmaker.dx.dex.code.LocalList, org.droidparts.dexmaker.dx.dex.code.PositionList, org.droidparts.dexmaker.dx.rop.annotation.AnnotationsList, org.droidparts.dexmaker.dx.rop.code.InsnList, org.droidparts.dexmaker.dx.rop.code.RegisterSpecList, org.droidparts.dexmaker.dx.rop.cst.CstArray.List, org.droidparts.dexmaker.dx.rop.type.StdTypeList
Imports
java.util.Arrays

Simple (mostly) fixed-size list of objects, which may be made immutable.

Field Summary

Modifier and TypeField and Description
private Object[]
arr

non-null; array of elements

Constructor Summary

AccessConstructor and Description
public
FixedSizeList(int
the size of the list
size
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
protected final Object

Returns:

non-null; the indicated element
get0
(int
>= 0, < size(); which element
n
)

Gets the indicated element.

protected final Object

Returns:

null-ok; the indicated element
getOrNull0
(int
>= 0, < size(); which element
n
)

Gets the indicated element, allowing nulls to be returned.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
protected final void
set0(int
>= 0, < size(); which element
n
,
Object
null-ok; the value to store
obj
)

Sets the element at the given index, but without doing any type checks on the element.

public void
shrinkToFit()

Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.

public final int
size()

Gets the number of elements in this list.

private Object

Returns:

never
throwIndex
(int
the index value
n
)

Throws the appropriate exception for the given index value.

public String
toHuman()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Return the "human" string form of this instance.
public String

Returns:

non-null; the custom string
toHuman
(String
null-ok; prefix for the start of the result
prefix
,
String
null-ok; separator to insert between each item
separator
,
String
null-ok; suffix for the end of the result
suffix
)

Gets a customized human string for this instance.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public String

Returns:

non-null; the custom string
toString
(String
null-ok; prefix for the start of the result
prefix
,
String
null-ok; separator to insert between each item
separator
,
String
null-ok; suffix for the end of the result
suffix
)

Gets a customized string form for this instance.

private String

Returns:

non-null; the custom string
toString0
(String
null-ok; prefix for the start of the result
prefix
,
String
null-ok; separator to insert between each item
separator
,
String
null-ok; suffix for the end of the result
suffix
,
boolean
whether the output is to be human
human
)

Helper for toString and toHuman, which both of those call to pretty much do everything.

Inherited from org.droidparts.dexmaker.dx.util.MutabilityControl:
isImmutableisMutablesetImmutablethrowIfImmutablethrowIfMutable

Field Detail

arrback to summary
private Object[] arr

non-null; array of elements

Constructor Detail

FixedSizeListback to summary
public FixedSizeList(int size)

Constructs an instance. All indices initially contain null.

Parameters
size:int

the size of the list

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
get0back to summary
protected final Object get0(int n)

Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.

Parameters
n:int

>= 0, < size(); which element

Returns:Object

non-null; the indicated element

getOrNull0back to summary
protected final Object getOrNull0(int n)

Gets the indicated element, allowing nulls to be returned. This method is protected so that subclasses may (optionally) offer a safe type-checked public interface to their clients.

Parameters
n:int

>= 0, < size(); which element

Returns:Object

null-ok; the indicated element

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
set0back to summary
protected final void set0(int n, Object obj)

Sets the element at the given index, but without doing any type checks on the element. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.

Parameters
n:int

>= 0, < size(); which element

obj:Object

null-ok; the value to store

shrinkToFitback to summary
public void shrinkToFit()

Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.

sizeback to summary
public final int size()

Gets the number of elements in this list.

throwIndexback to summary
private Object throwIndex(int n)

Throws the appropriate exception for the given index value.

Parameters
n:int

the index value

Returns:Object

never

Exceptions
IndexOutOfBoundsException:
always thrown
toHumanback to summary
public String toHuman()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Doc from org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Return the "human" string form of this instance. This is generally less "debuggy" than toString(). This method will only work if every element of the list implements ToHuman.

Returns:String

non-null; the human string form

toHumanback to summary
public String toHuman(String prefix, String separator, String suffix)

Gets a customized human string for this instance. This method will only work if every element of the list implements ToHuman.

Parameters
prefix:String

null-ok; prefix for the start of the result

separator:String

null-ok; separator to insert between each item

suffix:String

null-ok; suffix for the end of the result

Returns:String

non-null; the custom string

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(String prefix, String separator, String suffix)

Gets a customized string form for this instance.

Parameters
prefix:String

null-ok; prefix for the start of the result

separator:String

null-ok; separator to insert between each item

suffix:String

null-ok; suffix for the end of the result

Returns:String

non-null; the custom string

toString0back to summary
private String toString0(String prefix, String separator, String suffix, boolean human)

Helper for toString and toHuman, which both of those call to pretty much do everything.

Parameters
prefix:String

null-ok; prefix for the start of the result

separator:String

null-ok; separator to insert between each item

suffix:String

null-ok; suffix for the end of the result

human:boolean

whether the output is to be human

Returns:String

non-null; the custom string