ObjectPool.smali

.class public Lcom/github/mikephil/charting/utils/ObjectPool;
.super Ljava/lang/Object;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;",
        ">",
        "Ljava/lang/Object;"
    }
.end annotation


# static fields
.field private static g:I


# instance fields
.field private a:I

.field private b:I

.field private c:[Ljava/lang/Object;

.field private d:I

.field private e:Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "TT;"
        }
    .end annotation
.end field

.field private f:F


# direct methods
.method static constructor <clinit>()V
    .registers 0

    return-void
.end method

.method private constructor <init>(ILcom/github/mikephil/charting/utils/ObjectPool$Poolable;)V
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(ITT;)V"
        }
    .end annotation

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    if-lez p1, :cond_18

    iput p1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->b:I

    new-array p1, p1, [Ljava/lang/Object;

    iput-object p1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    const/4 p1, 0x0

    iput p1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    iput-object p2, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->e:Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;

    const/high16 p1, 0x3f800000    # 1.0f

    iput p1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->f:F

    invoke-direct {p0}, Lcom/github/mikephil/charting/utils/ObjectPool;->d()V

    return-void

    :cond_18
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "Object Pool must be instantiated with a capacity greater than 0!"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public static declared-synchronized a(ILcom/github/mikephil/charting/utils/ObjectPool$Poolable;)Lcom/github/mikephil/charting/utils/ObjectPool;
    .registers 4

    const-class v0, Lcom/github/mikephil/charting/utils/ObjectPool;

    monitor-enter v0

    :try_start_3
    new-instance v1, Lcom/github/mikephil/charting/utils/ObjectPool;

    invoke-direct {v1, p0, p1}, Lcom/github/mikephil/charting/utils/ObjectPool;-><init>(ILcom/github/mikephil/charting/utils/ObjectPool$Poolable;)V

    sget p0, Lcom/github/mikephil/charting/utils/ObjectPool;->g:I

    iput p0, v1, Lcom/github/mikephil/charting/utils/ObjectPool;->a:I

    sget p0, Lcom/github/mikephil/charting/utils/ObjectPool;->g:I

    add-int/lit8 p0, p0, 0x1

    sput p0, Lcom/github/mikephil/charting/utils/ObjectPool;->g:I
    :try_end_12
    .catchall {:try_start_3 .. :try_end_12} :catchall_14

    monitor-exit v0

    return-object v1

    :catchall_14
    move-exception p0

    monitor-exit v0

    throw p0
.end method

.method private d()V
    .registers 2

    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->f:F

    invoke-direct {p0, v0}, Lcom/github/mikephil/charting/utils/ObjectPool;->e(F)V

    return-void
.end method

.method private e(F)V
    .registers 6

    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->b:I

    int-to-float v1, v0

    mul-float v1, v1, p1

    float-to-int p1, v1

    const/4 v1, 0x1

    if-ge p1, v1, :cond_b

    const/4 v0, 0x1

    goto :goto_f

    :cond_b
    if-le p1, v0, :cond_e

    goto :goto_f

    :cond_e
    move v0, p1

    :goto_f
    const/4 p1, 0x0

    :goto_10
    if-ge p1, v0, :cond_1f

    iget-object v2, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    iget-object v3, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->e:Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;

    invoke-virtual {v3}, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a()Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;

    move-result-object v3

    aput-object v3, v2, p1

    add-int/lit8 p1, p1, 0x1

    goto :goto_10

    :cond_1f
    sub-int/2addr v0, v1

    iput v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    return-void
.end method

.method private f()V
    .registers 5

    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->b:I

    mul-int/lit8 v1, v0, 0x2

    iput v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->b:I

    new-array v1, v1, [Ljava/lang/Object;

    const/4 v2, 0x0

    :goto_9
    if-ge v2, v0, :cond_14

    iget-object v3, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    aget-object v3, v3, v2

    aput-object v3, v1, v2

    add-int/lit8 v2, v2, 0x1

    goto :goto_9

    :cond_14
    iput-object v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    return-void
.end method


# virtual methods
.method public declared-synchronized b()Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()TT;"
        }
    .end annotation

    monitor-enter p0

    :try_start_1
    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    const/4 v1, -0x1

    if-ne v0, v1, :cond_10

    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->f:F

    const/4 v1, 0x0

    cmpl-float v0, v0, v1

    if-lez v0, :cond_10

    invoke-direct {p0}, Lcom/github/mikephil/charting/utils/ObjectPool;->d()V

    :cond_10
    iget-object v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    iget v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    aget-object v0, v0, v1

    check-cast v0, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;

    sget v1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->b:I

    iput v1, v0, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a:I

    iget v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    add-int/lit8 v1, v1, -0x1

    iput v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I
    :try_end_22
    .catchall {:try_start_1 .. :try_end_22} :catchall_24

    monitor-exit p0

    return-object v0

    :catchall_24
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public declared-synchronized c(Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;)V
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TT;)V"
        }
    .end annotation

    monitor-enter p0

    :try_start_1
    iget v0, p1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a:I

    sget v1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->b:I

    if-eq v0, v1, :cond_33

    iget v0, p1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a:I

    iget v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->a:I

    if-ne v0, v1, :cond_15

    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string v0, "The object passed is already stored in this pool!"

    invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1

    :cond_15
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "The object to recycle already belongs to poolId "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget p1, p1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a:I

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string p1, ".  Object cannot belong to two different pool instances simultaneously!"

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_33
    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    iget-object v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    array-length v1, v1

    if-lt v0, v1, :cond_41

    invoke-direct {p0}, Lcom/github/mikephil/charting/utils/ObjectPool;->f()V

    :cond_41
    iget v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->a:I

    iput v0, p1, Lcom/github/mikephil/charting/utils/ObjectPool$Poolable;->a:I

    iget-object v0, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->c:[Ljava/lang/Object;

    iget v1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->d:I

    aput-object p1, v0, v1
    :try_end_4b
    .catchall {:try_start_1 .. :try_end_4b} :catchall_4d

    monitor-exit p0

    return-void

    :catchall_4d
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public g(F)V
    .registers 5

    const/4 v0, 0x0

    const/high16 v1, 0x3f800000    # 1.0f

    cmpl-float v2, p1, v1

    if-lez v2, :cond_a

    const/high16 p1, 0x3f800000    # 1.0f

    goto :goto_f

    :cond_a
    cmpg-float v1, p1, v0

    if-gez v1, :cond_f

    const/4 p1, 0x0

    :cond_f
    :goto_f
    iput p1, p0, Lcom/github/mikephil/charting/utils/ObjectPool;->f:F

    return-void
.end method