-
Notifications
You must be signed in to change notification settings - Fork 0
CSVS-57 CircleQueue was added #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
| } | ||
|
|
||
| protected def getClient(endpoint: String): ApacheCloudStackClient = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createClient()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| val secondElement = "2" | ||
| val thirdElement = "3" | ||
|
|
||
| "moveElementToEnd" should "move the first element to end of the queue" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"moveElementToEnd" should "move the first element to the end of the queue"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| assert(expectedResult == queue.getElements) | ||
| } | ||
|
|
||
| "moveElementToEnd" should "not change queue if element for move is not first" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"moveElementToEnd" should "not change a queue if an element is not first"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
|
||
| val cloudStackTaskCreator = new CloudStackTaskCreator(cloudStackTaskCreatorSettings) { | ||
| override val endpointQueue = new CircleQueue[String](cloudStackTaskCreatorSettings.endpoints.toList) | ||
| override val endpointQueue = getEndPointQueue(cloudStackTaskCreatorSettings.endpoints.toList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getEndpointQueue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
|
||
| def moveElementToEnd(element: T): Unit = synchronized { | ||
| val currentIndex = elements.indexOf(element) | ||
| if(currentIndex != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space between "if" and condition: if (currentIndex != -1) ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check the code below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| class WeightedQueue[T](private val elementList: List[T]) { | ||
| protected val r = new Random | ||
|
|
||
| private val lengthOfArray = elementList.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does the name contain "array"? is it a list or array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List
| elements = elements.take(currentIndex) ++ elements.takeRight(lengthOfArray - currentIndex - 1) :+ element | ||
| } | ||
| } else { | ||
| throw new IllegalArgumentException(s"Element: $element is not included in the initialization list: $elementList") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested element doesn't exist: $element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
|
||
| private val lengthOfArray = elementList.length | ||
| private val sumOfNumbers = getSumOfNumbers(0, lengthOfArray) | ||
| private val gradeScaleElements: RangeMap[Integer, Int] = TreeRangeMap.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elementIndexByPossibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
|
||
| private var elements = elementList | ||
|
|
||
| fillRangeMap(0, lengthOfArray, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| } | ||
| } | ||
|
|
||
| private def getSumOfNumbers(acc: Int, lenght: Int): Int = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSum() = N * (first + last) / 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| private val lengthOfArray = elementList.length | ||
| private val sumOfNumbers = getSumOfNumbers(0, lengthOfArray) | ||
| private val gradeScaleElements: RangeMap[Integer, Int] = TreeRangeMap.create() | ||
| private val lengthOfList = elementList.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just length or size
No description provided.