Java Code Examples for org.apache.tinkerpop.gremlin.util.NumberHelper#add()
The following examples show how to use
org.apache.tinkerpop.gremlin.util.NumberHelper#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SumLocalStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override protected E map(final Traverser.Admin<S> traverser) { final Iterator<E> iterator = traverser.get().iterator(); if (iterator.hasNext()) { Number result = iterator.next(); while (iterator.hasNext()) { result = NumberHelper.add(result, iterator.next()); } return (E) result; } throw FastNoSuchElementException.instance(); }
Example 2
Source File: MeanLocalStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override protected Number map(final Traverser.Admin<S> traverser) { final Iterator<E> iterator = traverser.get().iterator(); if (iterator.hasNext()) { Long counter = 1L; E result = iterator.next(); while (iterator.hasNext()) { result = (E) NumberHelper.add(result, iterator.next()); counter++; } return NumberHelper.div(result, counter, true); } throw FastNoSuchElementException.instance(); }
Example 3
Source File: MeanGlobalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
public MeanNumber add(final Number amount, final long count) { this.count += count; this.sum = NumberHelper.add(sum, mul(amount, count)); return this; }
Example 4
Source File: MeanGlobalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
public MeanNumber add(final MeanNumber other) { this.count += other.count; this.sum = NumberHelper.add(sum, other.sum); return this; }