 		return array.count == 0
 	}
 	
-	public func insert(element: T) {
+	public func insert(element: T, weight: W) {
 		array.append(element)
+		weights.append(weight)
 		elementsToPositions[element] = array.count - 1
 		
 		_heapifyUp(array.count - 1)
 	}
 	
-	public func update(element: T) {
-		if let position = elementsToPositions[element] {
-			_heapifyUp(position)
+	public func update(element: T, weight: W) {
+		if let index = elementsToPositions[element] {
+			weights[index] = weight
+			_heapifyUp(index)
 		}
 	}
 	


import Foundation

public class Heap<T where T: Comparable, T: Hashable> {
	private var array = [T]()
	private var elementsToPositions = Dictionary<T, Int>()
	
	private func _parentIndex(index: Int) -> Int {

		}
	}
	
	private func _swapElements(a: Int, _ b: Int) {
		let elementA = array[a]
		let elementB = array[b]
		
		let weightA = weights[a]
		let weightB = weights[b]
		
		array[a] = elementB
		array[b] = elementA
		
		weights[a] = weightB
		weights[b] = weightA
		
		elementsToPositions[elementA] = b
		elementsToPositions[elementB] = a
