Mergeable

com.phasmidsoftware.xmldoc.core.Mergeable
See theMergeable companion trait
object Mergeable

Companion object for Mergeable.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Mergeable.type

Members list

Value members

Concrete methods

def joinOrdered[A](first: Seq[A], second: Seq[A])(distance: (A, A) => Option[Double]): Seq[A]

Method to join two ordered sequences of elements at whichever end of second attaches more closely to the end of first, per the given distance function - without ever reversing (or reordering) first: its own orientation is authoritative, and it always comes first in the result. Only second may be reversed, if that yields a closer join.

Method to join two ordered sequences of elements at whichever end of second attaches more closely to the end of first, per the given distance function - without ever reversing (or reordering) first: its own orientation is authoritative, and it always comes first in the result. Only second may be reversed, if that yields a closer join.

This is deliberately generic (not tied to geometry, or to any particular element type): the only thing it needs to know about A is how far apart two instances of it are, if that's even defined (e.g. Issue #54 uses Coordinate.distance, but any "ordered sequence of things with a distance/compatibility notion between them" can reuse this).

Type parameters

A

the element type.

Value parameters

distance

a function yielding the distance between two elements, if defined.

first

the first sequence: appended as-is, never reversed, never reordered.

second

the second sequence: appended as-is, or reversed - whichever end attaches more closely to first's last element. If distance is undefined for both candidate joins (or either sequence is empty), second is appended as-is.

Attributes

Returns

the concatenation of first and (possibly-reversed) second.

def mergeOptions[T](ao: Option[T], bo: Option[T])(f: (T, T) => Option[T]): Option[T]

Method to merge two Optional values of the same type.

Method to merge two Optional values of the same type.

Type parameters

T

the underlying type.

Value parameters

ao

the first optional value.

bo

the second optional value.

f

a method to merge two elements of the underlying type T.

Attributes

Returns

an Option[T].

def mergeOptionsBiased[T](ao: Option[T], bo: Option[T]): Option[T]

Method to merge two Optional values of the same type.

Method to merge two Optional values of the same type.

NOTE: In this method, there is no proper merging of two defined values: we arbitrarily select the first.

Type parameters

T

the underlying type.

Value parameters

ao

the first optional value.

bo

the second optional value.

Attributes

Returns

an Option[T].

def mergeSequence[T <: Mergeable[T]](ts: Seq[T])(fail: => T): Seq[T]

Method to merge a Sequence into a Sequence of one.

Method to merge a Sequence into a Sequence of one.

NOTE the merge method assumes that it is associative with respect to T.

Type parameters

T

the underlying type (extends Mergeable).

Value parameters

fail

the value of T used for a merge failure.

ts

the sequence to be merged.

Attributes

Returns

Seq[T] with only one element.

def mergeStrings(ao: Option[String], bo: Option[String])(f: (String, String) => Option[String]): Option[String]

Method to merge two optional Strings.

Method to merge two optional Strings.

Value parameters

ao

the first optional String.

bo

the second optional String.

f

a function to combine two Strings and yield an Option[String].

Attributes

Returns

an Option[String].

def mergeStringsDelimited(ao: Option[String], bo: Option[String])(delimiter: String): Option[String]

Method to concatenate two optional Strings with a delimiter between them.

Method to concatenate two optional Strings with a delimiter between them.

Value parameters

ao

the first optional String.

bo

the second optional String.

delimiter

a String to be placed between the two given Strings.

Attributes

Returns

an Option[String].