Skip to content

Instantly share code, notes, and snippets.

View zekierciyas's full-sized avatar
🏠
Working from home

Zeki Erciyas zekierciyas

🏠
Working from home
View GitHub Profile
@zekierciyas
zekierciyas / CachedBruteForceSearching.kt
Created February 21, 2023 18:31
OptimizedSearchingAlgorithms
import com.zekierciyas.cache.model.satellite_list.SatelliteListItem
import java.util.*
class CachedBruteForceSearching(private val cacheSize: Int = 5) {
private var givenDataList: List<SatelliteListItem> = mutableListOf()
var cache: LinkedHashMap<String, List<SatelliteListItem>> = object : LinkedHashMap<String, List<SatelliteListItem>>(5, 0.75f, true) {
override fun removeEldestEntry(eldest: Map.Entry<String?, List<SatelliteListItem>>?): Boolean {
return size > cacheSize
@zekierciyas
zekierciyas / BitmapExtentions.kt
Last active August 4, 2022 19:25
BitmapExtentions
fun Bitmap.resizeImage(image: Bitmap, maxWidth: Int, maxHeight: Int, onComplete: (bitmap: Bitmap?) -> Unit) {
val width = image.width
val height = image.height
val scaleWidth = maxWidth.toFloat() / width
val scaleHeight = maxHeight.toFloat() / height
val matrix = Matrix()
matrix.postScale(scaleWidth, scaleHeight)