Category: Scala Sorted

Composite key handling, using @EmbeddedId annotation in scala

example simple : case class Group( id: Option[Id], category: Category, image: Option[FileResource] = None, updatedAt: LocalDateTime = NOW, createdAt: LocalDateTime = NOW ) extends EntityModel[Id] object Group { val Id = the[Identity[Id]] type Id = Long @@ GroupCommonIcon type WithNoId = Entity.WithNoId [Id, GroupCommonIcon] type EmbeddedId = Entity.EmbeddedId [Id, GroupCommonIcon] }

Advertisements

using Angular 5 Services

Generating the Service File The robust Anguar CLI tool will allow us to quickly and easily generate a service file for our project. Hop into your console within the project folder and run the following command: $ ng generate service data Working in the Service File Open up the file, located at: /src/app/data.service.ts: import { Injectable … Continue reading using Angular 5 Services

HeapSort in Scala – this is coding algorithm

import scala.collection.mutable.ArraySeq object HeapSort { def sort(vals: ArraySeq[Int]) { var heap = new MaxHeap heap.set(vals) for (i <- vals.length - 1 to 0 by -1) { vals(i) = heap.deleteMax } } } class MaxHeap { var _vals: ArraySeq[Int] = _ // First element is in 1, not 0. def set(vals: ArraySeq[Int]) { _vals = new … Continue reading HeapSort in Scala – this is coding algorithm

Selection Sort in Scala-This is coding algorithm

object Sort{ def selectionSort () : Unit = { var myArray = Array(4, 7, 8, 3, 1, 9, 2, 5, 0, 6) var buf:Int = 0; var min:Int = 0; for(i <- 0 to (myArray.length-1)) { min = i // j = i + 1; for (j <- (i+1) to (myArray.length)){ if ( myArray(min) > … Continue reading Selection Sort in Scala-This is coding algorithm

This is coding algorithm – Scala code bubble sort for loop

object Sort{ def bubbleSort () : Unit = { var myArray = Array(4, 7, 8, 3, 1, 9, 2, 5, 0, 6) var buf:Int = 0; for(i <- 0 to (myArray.length-1)) { for (j <- 1 to (myArray.length)){ if (myArray(j) < myArray(j-1)){ buf = myArray(j) myArray(j) = myArray(j-1) myArray(j-1) = buf } } } println("SORTED") … Continue reading This is coding algorithm – Scala code bubble sort for loop