Skip to content

Commit 6424a96

Browse files
author
Muhammad Hashim
committed
refactoring.
1 parent eaab1fd commit 6424a96

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

.idea/modules/Kotlin2DArrays.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111

1212
group 'com.github.mhashim6'
13-
version '1.0.0'
13+
version '1.0.1'
1414

1515
apply plugin: 'java'
1616
apply plugin: 'kotlin'
@@ -23,8 +23,8 @@ repositories {
2323
}
2424

2525
dependencies {
26-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
27-
testCompile "junit:junit:4.12"
26+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
27+
testImplementation "junit:junit:4.12"
2828

2929
}
3030

src/main/kotlin/mhashim6/kotlin/arrays2d/IndexedValue2D.kt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/kotlin/mhashim6/kotlin/arrays2d/IndexingIterable2D.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/kotlin/mhashim6/kotlin/arrays2d/IndexingIterator2D.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package mhashim6.kotlin.arrays2d
2+
3+
data class IndexedValue2D<out T>(var x: Int, var y: Int, val value: T)
4+
5+
class IndexingIterable2D<out T>(private val iteratorFactory: () -> Iterator2D<T>) : Iterable<IndexedValue2D<T>> {
6+
7+
override fun iterator(): Iterator<IndexedValue2D<T>> = IndexingIterator2D(iteratorFactory.invoke())
8+
}
9+
10+
class IndexingIterator2D<out T>(private val iterator: Iterator2D<T>) : Iterator<IndexedValue2D<T>> {
11+
12+
override fun hasNext() = iterator.hasNext()
13+
override fun next() = IndexedValue2D(iterator.x, iterator.y, iterator.next())
14+
}

0 commit comments

Comments
 (0)