Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ nmHoistingLimits: workspaces

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.6.1.cjs
21 changes: 10 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Contributor Covenant Code of Conduct

## Our Pledge
Expand All @@ -18,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down
80 changes: 80 additions & 0 deletions android/src/main/java/com/mapboxnavigation/LRUCache.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class LRUCache<K, V>(private val capacity: Int) {

private inner class Node(
val key: K,
var value: V,
var prev: Node? = null,
var next: Node? = null
)

private val map = HashMap<K, Node>()
private var head: Node? = null // Most recently used
private var tail: Node? = null // Least recently used

init {
require(capacity > 0) { "LRUCache capacity must be greater than 0" }
}

@Synchronized
fun get(key: K): V? {
val node = map[key] ?: return null
moveToHead(node)
return node.value
}

@Synchronized
fun put(key: K, value: V) {
val node = map[key]
if (node != null) {
node.value = value
moveToHead(node)
} else {
val newNode = Node(key, value)
map[key] = newNode
addToHead(newNode)

if (map.size > capacity) {
removeTail()?.let { removed -> map.remove(removed.key) }
}
}
}

// ==== Private helpers ====
private fun moveToHead(node: Node) {
removeNode(node)
addToHead(node)
}

private fun addToHead(node: Node) {
node.prev = null
node.next = head
head?.prev = node
head = node
if (tail == null) {
tail = node
}
}

private fun removeNode(node: Node) {
val prev = node.prev
val next = node.next

if (prev != null) {
prev.next = next
} else {
head = next
}

if (next != null) {
next.prev = prev
} else {
tail = prev
}
}

private fun removeTail(): Node? {
val node = tail ?: return null
removeNode(node)
return node
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class MapboxNavigationViewPackage : ReactPackage {
}

override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return emptyList()
return listOf(ParticipantsManager(reactContext))
}
}
Loading
Loading