Packages

  • package root
    Definition Classes
    root
  • package o1

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University.

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University. It contains an assortment of tools; most prominently, it provides a framework for simple graphical programming and utilities for playing sound.

    This is the front page of O1Library’s documentation. However, this is probably not the best place to start learning about O1Library as a student. That’s because the relevant content of this library is introduced bit by bit in the chapters of O1’s custom ebook alongside the associated programming concepts and assignments.

    You may still find this documentation useful as a reference. You can also find some optional content here that you may wish to try.

    This front page lists the content available in the top-level package called simply o1. These tools are available with the simple command import o1._ in your Scala programs. Some of them you’ll use a lot; some of them you won’t necessarily need at all.

    The tools listed here are actually implemented in a number of subpackages (o1.gui, o1.sound, etc.); what you see here are just “shortcut aliases” to those actual implementations. The aliases are here to make that convenient import command work and to provide you with this list of links to some of the more commonly used tools in O1Library. The subpackages also contain additional content not listed here.

    O1Library has been developed by Aleksi Lukkarinen and Juha Sorva. Several of the key components in o1.gui and o1.world are built upon Aleksi’s Scala Media Computation Library. Some parts of O1Library draw inspiration from the “teachpacks” of the Racket programming language.

    We are grateful to Riku Autio, Joonatan Honkamaa, Juhani Numminen, Leo Varis, Veera Kahva, and anonymous students for bug reports and fixes. We thank Otto Seppälä for helpful discussions.

    Definition Classes
    root
  • package util

    The package o1.util contains miscellaneous tools that are used internally by some of the given programs in O1 for added convenience.

    The package o1.util contains miscellaneous tools that are used internally by some of the given programs in O1 for added convenience.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used.

    This documentation lists only some of the tools in the package. The listed tools are largely a mix of:

    • functions for simple I/O from files and URLs;
    • aliases for easy access (via import o1.util._) to some of the tools from scala.util; and
    • implicit classes that add a few convenience methods to selected types from the Scala API.
    Definition Classes
    o1
  • ConvenientCollection
  • ConvenientDouble
  • ConvenientFloat
  • ConvenientInt
  • ConvenientLong
  • ConvenientMap
  • ConvenientOption
  • ConvenientPath
  • ConvenientSeq
c

o1.util

ConvenientCollection

implicit final class ConvenientCollection[Element, Collection[Element] <: Iterable[Element]] extends AnyVal

This class extends the interface of scala.Iterable with convenience methods.

Linear Supertypes
AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ConvenientCollection
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ConvenientCollection(self: Collection[Element])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def frequencies: Map[Element, Int]

    Constructs and returns a new map with the collection’s elements as keys and each element’s occurrence counts as the corresponding values.

    Constructs and returns a new map with the collection’s elements as keys and each element’s occurrence counts as the corresponding values. This is equivalent to mapGroups(identity)( _.size ).

  6. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  7. def ifNonEmpty[Result](compute: (Collection[Element]) => Result): Option[Result]

    Applies the given function to the collection in case there’s at least one element there.

    Applies the given function to the collection in case there’s at least one element there. Returns None if the collection is empty.

  8. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  9. def log(format: (Iterable[Element]) => String = _.toString): Collection[Element]

    Prints out the collection, then returns the unmodified collection.

    Prints out the collection, then returns the unmodified collection.

    format

    a function from the collection to the desired printout; defaults to _.toString

  10. def mapFromID[ID](formID: (Element) => ID): Map[ID, Element]

    Constructs and returns a new map by applying an ID-generating function to each element of the collection and using the collection’s elements as values.

    Constructs and returns a new map by applying an ID-generating function to each element of the collection and using the collection’s elements as values. This is equivalent to calling mapify(formID)(identity).

    formID

    a function called on each element of the collection to obtain the keys

  11. def mapGroups[Key, Value](formKey: (Element) => Key)(transformGroup: (Iterable[Element]) => Value): Map[Key, Value]

    Constructs and returns a new map by using one given function to group the elements of the collection (as per groupBy) and then transforming each of the groups using another given function (as per mapValues).

    Constructs and returns a new map by using one given function to group the elements of the collection (as per groupBy) and then transforming each of the groups using another given function (as per mapValues).

    formKey

    a function called on each element of the collection to generate groups of values

    transformGroup

    a function called on each group to obtain the values for the resulting collection

  12. def mapTo[Value](formValue: (Element) => Value): Map[Element, Value]

    Constructs and returns a new map by applying a value-generating function to each element of the collection and using the collection’s elements as keys.

    Constructs and returns a new map by applying a value-generating function to each element of the collection and using the collection’s elements as keys. This is equivalent to calling mapify(identity)(formValue).

    formValue

    a function called on each element of the collection to obtain the keys

  13. def mapify[Key, Value](formKey: (Element) => Key)(formValue: (Element) => Value): Map[Key, Value]

    Constructs and returns a new map by applying a key-generating function as well as a value-generating function to each element of the collection.

    Constructs and returns a new map by applying a key-generating function as well as a value-generating function to each element of the collection. The respective outputs of the functions are paired to form the key--value pairs of the Map.

    formKey

    a function called on each element of the collection to obtain the keys

    formValue

    a function called on each element of the collection to obtain the values

  14. def slidingPairs: Iterator[(Element, Element)]

    Returns an iterator of pairs (tuples) that “slide across” the collection as per sliding.

  15. def tap(effect: (Element) => Unit): Collection[Element]

    Performs a given side effect at each element of the collection.

    Performs a given side effect at each element of the collection. Returns the unmodified collection.

  16. def toLazy: LazyList[Element]

    Returns a LazyList containing the collection’s elements.

    Returns a LazyList containing the collection’s elements. This is equivalent to to(LazyList).

  17. def toString: String
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped