12/29/2023 0 Comments Linked hashmapThe implementation of equals checks the canEqual method, so subclasses of Map can narrow down the equality for every (key, value) pair in this map, other.get(key) = Some(value).Definition Classes AnyRefĮquality of maps is implemented using the lookup method get.Įquality of maps is implemented using the lookup method get. True if the argument is a reference to the receiver object false otherwise. Should be equal to each other ( o1 = o2) and they should hash to the same value ( o1.hashCode = o2.hashCode). Therefore, if two objects are references to each other ( o1 eq o2), they When overriding the equals or hashCode methods, it is important to ensure that their behavior isĬonsistent with reference equality. For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.X.eq(y) consistently returns true or consistently returns false. It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of.Non-null instances of AnyRef, and has three additional properties: The eq method implements an equivalence relation on Tests whether the argument ( that) is a reference to the receiver object ( this). Definition Classes MapOps → PartialFunctionĬast the receiver object to be of type T0. The result of this function or fallback function application. This may result in better performanceĪnd more predictable behavior w.r.t. It is recommended to override applyOrElse with custom implementation that avoidsĭouble isDefinedAt evaluation. runWith allows efficient imperative-style combining of partial functionsįor non-literal partial function classes with nontrivial isDefinedAt method.lift and unlift do not evaluate source functions twice on each invocation.combining partial functions into orElse/ andThen chains does not lead to.This makes applyOrElse the basis for the efficient implementation for many operations and scenarios, such as: Note that expression pf.applyOrElse(x, default) is equivalent to if(pf isDefinedAt x) pf(x) else default(x)Įxcept that applyOrElse method can be implemented more efficiently.įor all partial function literals the compiler generates an applyOrElse implementation whichĪvoids double evaluation of pattern matchers and guards. Definition Classes rootĭefaultSerializable, java.io.Serializable, StrictOptimizedMapOps], StrictOptimizedIterableOps Iterable, LinkedHashMap], SeqMap, collection.SeqMap, AbstractMap, Map, MapOps LinkedHashMap, LinkedHashMap], Shrinkable, Builder], Growable, Clearable, Cloneable],, Iterable, collection.AbstractMap, collection.Map, Equals, MapFactoryDefaults LinkedHashMap, Iterable], collection.MapOps LinkedHashMap, LinkedHashMap], PartialFunction, ( K) => V, collection.AbstractIterable, collection.Iterable, IterableFactoryDefaults Iterable], IterableOps Iterable, LinkedHashMap], IterableOnceOps Iterable, LinkedHashMap], IterableOnce, AnyRef, AnyĪpplies this partial function to the given argument when it is contained in the function domain.Īpplies fallback function where this partial function is not defined. For example, on the JVM, String is an alias for. Other aliases refer to classes provided by the underlying platform. Some of these identifiers are type aliases provided as shortcuts to commonly used classes. Identifiers in the scala package and the scala.Predef object are always in scope by default. scala.swing - A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar).- Parser combinators (scala-parser-combinators.jar). ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |