Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f89f06

Browse files
changed the increase size coefficient for the DynamicArray.increaseSize() method
1 parent 86c2d13 commit 1f89f06

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/main/kotlin/structures/DynamicArray.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ class DynamicArray<T>(private var capacity: Int = 10) {
125125
}
126126

127127
private fun increaseSize() {
128-
capacity *=2
128+
capacity = (capacity *INCREASE_SIZE_COEFFICIENT).toInt()
129129
val newArray = arrayOfNulls<Any>(capacity)
130130
for (i in data.indices) {
131131
newArray[i] = data[i]
132132
}
133133
data = newArray
134134
}
135135

136+
companion object {
137+
private const val INCREASE_SIZE_COEFFICIENT = 1.5f
138+
}
139+
136140
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /