public void update(int nodeIndex, double change, boolean positive) { double a = alphas.$get(nodeIndex); double b = betas.$get(nodeIndex); if (positive) alphas.$set(nodeIndex, a+change); else betas.$set(nodeIndex,b+change); activations.$set(nodeIndex,(a+(positive ? change : 0))/(a+b+change)); updated.$set(nodeIndex,true); }
/** * Removes an owner from the object, if the owner does exist. * Note that this method invalidates all signatures. * * @param {EcPk} oldOwner PK to remove. * @method removeOwner */ public void removeOwner(EcPk oldOwner) { String pem = oldOwner.toPem(); if (owner == null) owner = new Array<String>(); for (int i = 0; i < owner.$length(); i++) if (owner.$get(i) == pem) owner.splice(i, 1); // Changing an owner invalidates the signatures in order to prevent // server admins from injecting owners or readers into the object. signature = null; }
@Override public void $invoke(Array<EcRemoteLinkedData> p1) { if (success != null) { Array<EcAssertion> ret = JSCollections.$array(); for (int i = 0; i < p1.$length(); i++) { EcAssertion assertion = new EcAssertion(); assertion.copyFrom(p1.$get(i)); ret.$set(i, assertion); } success.$invoke(ret); } }
/** * Removes the first element from this <tt>Array</tt> and returns it. * * <p> * If this <tt>Array</tt> is empty, <tt>null</tt> is returned. * * @return the first element of this <tt>Array</tt>. */ public V shift() { Array<V> removed = this.splice(0, 1); if (removed.$length() == 1) { return removed.$get(0); } return null; }
/** * Appends all the specified elements in the order they appear in the arguments list to the elements of this * <tt>Array</tt>. This method does not change the existing arrays, but returns a new array, containing the values * of the joined arrays. * * @param values * the elements to be concatenated to this <tt>Array</tt> * @return a new <tt>Array</tt>, containing all the elements of the joined <tt>Arrays</tt>. */ @SafeVarargs public final Array<V> concat(V... values) { Array<V> result = new Array<V>(); // add the elements of this array long i = 0; Iterator<Entry<V>> iter = this.entryIterator(0, this.$length(), true); while (iter.hasNext()) { Entry<V> entry = iter.next(); result.$set(i + entry.key, entry.value); } i = this.$length(); result.$length(this.$length()); if (values != null) { // add the specified values for (int j = 0; j < values.length; j++) { result.$set(i + j, values[j]); } } return result; }
private void startFindCycles(NodeRelationMap relationMap, NodePacketGraph npg) { Array<Node> nodeList = relationMap.getNodeList(); for (int i=0;i<nodeList.$length();i++) { visitedNodes = new Array<Node>(); //this may be something we can change for efficiency...I was alternating between these two to see if there was any difference... //if (!nodesProcessed.contains(n)) findCycles(n,relationMap,npg,new ArrayList<Node>()); findCycles(nodeList.$get(i),relationMap,npg); } }
@Override public void $invoke(Array<EcRemoteLinkedData> p1) { if (success != null) { Array<EcAlignment> ret = JSCollections.$array(); for (int i = 0; i < p1.$length(); i++) { EcAlignment alignment = new EcAlignment(); if (p1.$get(i).isAny(alignment.getTypes())) { alignment.copyFrom(p1.$get(i)); } else if (p1.$get(i).isA(EcEncryptedValue.myType)) { EcEncryptedValue val = new EcEncryptedValue(); val.copyFrom(p1.$get(i)); if (val.isAnEncrypted(EcAlignment.myType)) { EcRemoteLinkedData obj = val.decryptIntoObject(); if (sourceIds.indexOf((String) JSObjectAdapter.$get(obj, "source")) == -1 && finalNoVersions.indexOf((String) JSObjectAdapter.$get(obj, "source")) == -1) { continue; } alignment.copyFrom(obj); } } ret.$set(i, alignment); } success.$invoke(ret); } }
/** * The specified elements are appended at the end of this <tt>Array</tt> in the order in which they appear in the * arguments list and the new length of this <tt>Array</tt> is returned. * * @param values * the values to be appended * @return the new length of this <tt>Array</tt> */ @SafeVarargs public final int push(V... values) { this.splice(this.$length(), 0, values); return (int) this.length; }
/** * Removes the last element from this <tt>Array</tt> and returns it. * * <p> * If this <tt>Array</tt> is empty, <tt>undefined</tt> is returned. * * @return the last element from this <tt>Array</tt> */ public V pop() { if (this.length == 0) { return null; } Array<V> removed = this.splice((int) (this.length - 1), 1); return removed.$get(0); }
@Override public void $invoke(String encryptedSecret) { v.secret.push(encryptedSecret); success.$invoke(); } }, failure);
@Override public void $invoke(Array<EcIdentity> pks) { Array cache = null; String stringified = JSGlobal.JSON.stringify(signatures); if (signatureSheetCaching) { cache = new Array(); cache.$set(0, new Date().getTime() + finalDuration); cache.$set(1, stringified); JSObjectAdapter.$put(signatureSheetCache, server, cache); } success.$invoke(stringified); } });
long actualStart; if (start < 0) { actualStart = (long) Math.max(0, this.$length() + start); } else { actualStart = (long) Math.min(this.$length(), start); Iterator<Entry<V>> iter = this.entryIterator(actualStart, this.$length(), true); return indexOf(element, iter);
private ResultType getPacketAssertionResult(InquiryPacket ip) { if (ip.positive.$length() > 0 && ip.negative.$length() == 0) { return ResultType.TRUE; } else if (ip.positive.$length() == 0 && ip.negative.$length() > 0) { return ResultType.FALSE; } else if (ip.positive.$length() > 0 && ip.negative.$length() > 0) { return ResultType.INDETERMINANT; } else { return ResultType.UNKNOWN; } }