123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574 |
- .class public final Landroid/support/v4/util/CircularIntArray;
- .super Ljava/lang/Object;
- .source "CircularIntArray.java"
- # instance fields
- .field private mCapacityBitmask:I
- .field private mElements:[I
- .field private mHead:I
- .field private mTail:I
- # direct methods
- .method public constructor <init>()V
- .locals 1
- .prologue
- .line 48
- const/16 v0, 0x8
- invoke-direct {p0, v0}, Landroid/support/v4/util/CircularIntArray;-><init>(I)V
- .line 49
- return-void
- .end method
- .method public constructor <init>(I)V
- .locals 3
- .param p1, "minCapacity" # I
- .prologue
- const/4 v2, 0x1
- .line 57
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- .line 58
- if-ge p1, v2, :cond_0
- .line 59
- new-instance v1, Ljava/lang/IllegalArgumentException;
- const-string v2, "capacity must be >= 1"
- invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw v1
- .line 61
- :cond_0
- const/high16 v1, 0x40000000 # 2.0f
- if-le p1, v1, :cond_1
- .line 62
- new-instance v1, Ljava/lang/IllegalArgumentException;
- const-string v2, "capacity must be <= 2^30"
- invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw v1
- .line 68
- :cond_1
- invoke-static {p1}, Ljava/lang/Integer;->bitCount(I)I
- move-result v1
- if-eq v1, v2, :cond_2
- .line 69
- add-int/lit8 v1, p1, -0x1
- invoke-static {v1}, Ljava/lang/Integer;->highestOneBit(I)I
- move-result v1
- shl-int/lit8 v0, v1, 0x1
- .line 74
- .local v0, "arrayCapacity":I
- :goto_0
- add-int/lit8 v1, v0, -0x1
- iput v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- .line 75
- new-array v1, v0, [I
- iput-object v1, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- .line 76
- return-void
- .line 71
- .end local v0 # "arrayCapacity":I
- :cond_2
- move v0, p1
- .restart local v0 # "arrayCapacity":I
- goto :goto_0
- .end method
- .method private doubleCapacity()V
- .locals 7
- .prologue
- const/4 v6, 0x0
- .line 29
- iget-object v4, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- array-length v1, v4
- .line 30
- .local v1, "n":I
- iget v4, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- sub-int v3, v1, v4
- .line 31
- .local v3, "r":I
- shl-int/lit8 v2, v1, 0x1
- .line 32
- .local v2, "newCapacity":I
- if-gez v2, :cond_0
- .line 33
- new-instance v4, Ljava/lang/RuntimeException;
- const-string v5, "Max array capacity exceeded"
- invoke-direct {v4, v5}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V
- throw v4
- .line 35
- :cond_0
- new-array v0, v2, [I
- .line 36
- .local v0, "a":[I
- iget-object v4, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v5, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- invoke-static {v4, v5, v0, v6, v3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
- .line 37
- iget-object v4, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v5, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- invoke-static {v4, v6, v0, v3, v5}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
- .line 38
- iput-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- .line 39
- iput v6, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- .line 40
- iput v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- .line 41
- add-int/lit8 v4, v2, -0x1
- iput v4, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- .line 42
- return-void
- .end method
- # virtual methods
- .method public addFirst(I)V
- .locals 2
- .param p1, "e" # I
- .prologue
- .line 83
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- add-int/lit8 v0, v0, -0x1
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v0, v1
- iput v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- .line 84
- iget-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- aput p1, v0, v1
- .line 85
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v0, v1, :cond_0
- .line 86
- invoke-direct {p0}, Landroid/support/v4/util/CircularIntArray;->doubleCapacity()V
- .line 88
- :cond_0
- return-void
- .end method
- .method public addLast(I)V
- .locals 2
- .param p1, "e" # I
- .prologue
- .line 95
- iget-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- aput p1, v0, v1
- .line 96
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- add-int/lit8 v0, v0, 0x1
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v0, v1
- iput v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- .line 97
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- if-ne v0, v1, :cond_0
- .line 98
- invoke-direct {p0}, Landroid/support/v4/util/CircularIntArray;->doubleCapacity()V
- .line 100
- :cond_0
- return-void
- .end method
- .method public clear()V
- .locals 1
- .prologue
- .line 131
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iput v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- .line 132
- return-void
- .end method
- .method public get(I)I
- .locals 3
- .param p1, "n" # I
- .prologue
- .line 195
- if-ltz p1, :cond_0
- invoke-virtual {p0}, Landroid/support/v4/util/CircularIntArray;->size()I
- move-result v0
- if-lt p1, v0, :cond_1
- :cond_0
- new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v0}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v0
- .line 196
- :cond_1
- iget-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- add-int/2addr v1, p1
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v1, v2
- aget v0, v0, v1
- return v0
- .end method
- .method public getFirst()I
- .locals 2
- .prologue
- .line 174
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v0, v1, :cond_0
- new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v0}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v0
- .line 175
- :cond_0
- iget-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- aget v0, v0, v1
- return v0
- .end method
- .method public getLast()I
- .locals 3
- .prologue
- .line 184
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v0, v1, :cond_0
- new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v0}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v0
- .line 185
- :cond_0
- iget-object v0, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- add-int/lit8 v1, v1, -0x1
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v1, v2
- aget v0, v0, v1
- return v0
- .end method
- .method public isEmpty()Z
- .locals 2
- .prologue
- .line 212
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v0, v1, :cond_0
- const/4 v0, 0x1
- :goto_0
- return v0
- :cond_0
- const/4 v0, 0x0
- goto :goto_0
- .end method
- .method public popFirst()I
- .locals 3
- .prologue
- .line 108
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v1, v2, :cond_0
- new-instance v1, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v1}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v1
- .line 109
- :cond_0
- iget-object v1, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- aget v0, v1, v2
- .line 110
- .local v0, "result":I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- add-int/lit8 v1, v1, 0x1
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v1, v2
- iput v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- .line 111
- return v0
- .end method
- .method public popLast()I
- .locals 4
- .prologue
- .line 120
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- iget v3, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- if-ne v2, v3, :cond_0
- new-instance v2, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v2}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v2
- .line 121
- :cond_0
- iget v2, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- add-int/lit8 v2, v2, -0x1
- iget v3, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int v1, v2, v3
- .line 122
- .local v1, "t":I
- iget-object v2, p0, Landroid/support/v4/util/CircularIntArray;->mElements:[I
- aget v0, v2, v1
- .line 123
- .local v0, "result":I
- iput v1, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- .line 124
- return v0
- .end method
- .method public removeFromEnd(I)V
- .locals 2
- .param p1, "numOfElements" # I
- .prologue
- .line 159
- if-gtz p1, :cond_0
- .line 166
- :goto_0
- return-void
- .line 162
- :cond_0
- invoke-virtual {p0}, Landroid/support/v4/util/CircularIntArray;->size()I
- move-result v0
- if-le p1, v0, :cond_1
- .line 163
- new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v0}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v0
- .line 165
- :cond_1
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- sub-int/2addr v0, p1
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v0, v1
- iput v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- goto :goto_0
- .end method
- .method public removeFromStart(I)V
- .locals 2
- .param p1, "numOfElements" # I
- .prologue
- .line 142
- if-gtz p1, :cond_0
- .line 149
- :goto_0
- return-void
- .line 145
- :cond_0
- invoke-virtual {p0}, Landroid/support/v4/util/CircularIntArray;->size()I
- move-result v0
- if-le p1, v0, :cond_1
- .line 146
- new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException;
- invoke-direct {v0}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>()V
- throw v0
- .line 148
- :cond_1
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- add-int/2addr v0, p1
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v0, v1
- iput v0, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- goto :goto_0
- .end method
- .method public size()I
- .locals 2
- .prologue
- .line 204
- iget v0, p0, Landroid/support/v4/util/CircularIntArray;->mTail:I
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mHead:I
- sub-int/2addr v0, v1
- iget v1, p0, Landroid/support/v4/util/CircularIntArray;->mCapacityBitmask:I
- and-int/2addr v0, v1
- return v0
- .end method
|