inf2kva/src/main/scala/ScalaGo/SimpleList.scala
2024-02-23 21:44:58 +01:00

40 lines
1003 B
Scala

package ScalaGo
object SimpleList:
/**
* Implements a basic linked list.
*
* @param entry entry of the list element, 'None' if not provided
* @param next next element of the list, 'null' if not provided
* @tparam A type of the list's entries
*/
class SimpleList[A](var entry: Option[A] = None, var next: SimpleList[A] = null)
/**
* Append an item to the SimpleList
*
* @param list the list
* @param item append this item
*/
def append[A](list: SimpleList[A], item: A): Unit = ???
/**
* Determines the length of the SimpleList.
*
* @param list the list
* @return the length
*/
def length[A](list: SimpleList[A]): Int = ???
/**
* Tests if the SimpleList contains a given element.
*
* Tests for equality are done via '=='.
*
* @param list the list
* @param item search for this item
* @return true if the SimpleList contains the item, false if not
*/
def contains[A](list: SimpleList[A], item: A): Boolean = ???