Fixing remove runtime
This commit is contained in:
parent
4e1ecbc83c
commit
e2ded68b19
|
@ -144,7 +144,7 @@ textbook: "Ch. 7"
|
||||||
|
|
||||||
<p>Implementing <tt>insert</tt>.</p>
|
<p>Implementing <tt>insert</tt>.</p>
|
||||||
|
|
||||||
<pre style="transform: scale(0.8); margin-top: -50px; margin-bottom: -50px;" class="fragment"><code class="scala">
|
<pre style="transform: scale(0.8); margin-top: -50px; margin-bottom: -50px;"><code class="scala">
|
||||||
def insert(idx: Int, value: T): Unit =
|
def insert(idx: Int, value: T): Unit =
|
||||||
{
|
{
|
||||||
if(idx == 0){
|
if(idx == 0){
|
||||||
|
@ -207,10 +207,10 @@ textbook: "Ch. 7"
|
||||||
def sum(list: List[Int]): Unit =
|
def sum(list: List[Int]): Unit =
|
||||||
{
|
{
|
||||||
val total: Int = 0
|
val total: Int = 0
|
||||||
val curr = list.head
|
val current = list.head
|
||||||
while(curr.isDefined){
|
while(current.isDefined){
|
||||||
total += curr.get.value
|
total += current.get.value
|
||||||
curr = curr.get.next
|
current = current.get.next
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue