org.stjs.javascript.Array.splice()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 JavaScript  
字(6.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.stjs.javascript.Array.splice()方法的一些代码示例,展示了Array.splice()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.splice()方法的具体详情如下:
包路径:org.stjs.javascript.Array
类名称:Array
方法名:splice

Array.splice介绍

[英]Deletes the specified number of elements from this Array starting at specified start index, and returns a new Array containing the deleted elements (if any).

If start is negative, it is treated as length+start.
[中]从指定的开始索引处从此数组中删除指定数量的元素,并返回包含已删除元素(如果有)的新数组。
如果开始为负值,则将其视为长度+开始。

代码示例

代码示例来源:origin: com.eduworks/cass.competency

@Override
  public void $invoke(EcLevel a) {
    if (a.competency == shortId || a.competency == id) {
      me.level.splice(i, 1);
      me.removeLevelsThatInclude(id, i, success, failure);
    } else
      me.removeLevelsThatInclude(id, i + 1, success, failure);
  }
}, new Callback1<String>() {

代码示例来源:origin: com.eduworks/cass.competency

@Override
  public void $invoke(EcAlignment a) {
    if (a != null && a.source == shortId || a.target == shortId || a.source == id || a.target == id) {
      me.relation.splice(i, 1);
      me.removeRelationshipsThatInclude(id, i, success, failure);
    } else
      me.removeRelationshipsThatInclude(id, i + 1, success, failure);
  }
}, new Callback1<String>() {

代码示例来源:origin: org.st-js/shared

/**
 * Deletes the specified number of elements from this <tt>Array</tt> starting at specified start index, and returns
 * a new <tt>Array</tt> containing the deleted elements (if any).
 *
 * <p>
 * If <tt>start</tt> is negative, it is treated as <tt>length+start</tt>.
 *
 * @param start
 *            the index at which to start deleting elements. Use negative values to specified an index starting from
 *            the end
 * @param deleteCount
 *            the number of elements to be deleted
 * @return a new <tt>Array</tt> containing the deleted elements (if any)
 */
public Array<V> splice(int start, int deleteCount) {
  return this.splice(start, deleteCount, (V[]) null);
}

代码示例来源:origin: org.st-js/shared

/**
 * Prepends the specified values to the start of this <tt>Array</tt>, such that their order within this
 * <tt>Array</tt> is the same as the order in which they appear in the argument list. Returns the new length of this
 * <tt>Array</tt>.
 *
 * @param values
 *            the values to the prepended to the start of this <tt>Array</tt>
 * @return the new length of this <tt>Array</tt>
 */
@SafeVarargs
public final int unshift(V... values) {
  this.splice(0, 0, values);
  return this.$length();
}

代码示例来源:origin: org.st-js/shared

/**
 * 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);
}

代码示例来源:origin: org.st-js/shared

/**
 * 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;
}

代码示例来源:origin: org.st-js/shared

@Template("array")
@SafeVarargs
public static <V> Array<V> $array(V... values) {
  Array<V> a = new Array<V>();
  a.splice(0, 0, values);
  return a;
}

代码示例来源:origin: org.st-js/shared

/**
 * 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;
}

代码示例来源:origin: com.eduworks/org.cassproject.schema.cass

/***
 * Removes an assertion from the envelope
 * @param assertionShortIdToRemove
 * @method removeAssertionByShortId
 */
public void removeAssertionByShortId(String assertionShortIdToRemove) {
  if (assertion != null) {
    for (int i=0;i<assertion.$length();i++) {
      if (getAssertion(i).shortId().equals(assertionShortIdToRemove)) {
        assertion.splice(i, 1);
        break;
      }
    }
  }
  if (codebook != null) {
    for (int i=0;i<codebook.$length();i++) {
      if (codebook.$get(i).assertionShortId.equals(assertionShortIdToRemove)) {
        codebook.splice(i, 1);
        break;
      }
    }
  }
}

代码示例来源:origin: com.eduworks/cass.competency

/**
 * Removes a relation ID from the framework's list of relations
 *
 * @param {String} id
 *                 ID to remove from the framework's relation list
 * @memberOf EcFramework
 * @method removeCompetency
 */
public void removeRelation(String id) {
  id = trimVersionFromUrl(id);
  if (relation == null)
    relation = new Array<String>();
  for (int i = 0; i < relation.$length(); i++)
    if (trimVersionFromUrl(relation.$get(i)).equals(id))
      relation.splice(i, 1);
}

代码示例来源:origin: com.eduworks/cass.competency

/**
 * Removes a rollup rule ID from the framework's list of rollup rules
 *
 * @param {String} id
 *                 ID to remove from rollup rule list
 * @memberOf EcFramework
 * @method removeRollupRule
 */
public void removeRollupRule(String id) {
  id = trimVersionFromUrl(id);
  if (rollupRule == null)
    rollupRule = new Array<String>();
  for (int i = 0; i < rollupRule.$length(); i++)
    if (trimVersionFromUrl(rollupRule.$get(i)).equals(id))
      rollupRule.splice(i, 1);
}

代码示例来源:origin: com.eduworks/cass.competency

/**
 * Removes a level ID from the framework's list of levels
 *
 * @param {String} id
 *                 ID to remove from framework's level list
 * @memberOf EcFramework
 * @method removeLevel
 */
public void removeLevel(String id) {
  id = trimVersionFromUrl(id);
  if (level == null)
    level = new Array<String>();
  for (int i = 0; i < level.$length(); i++)
    if (trimVersionFromUrl(level.$get(i)).equals(id))
      level.splice(i, 1);
}

代码示例来源:origin: com.eduworks/org.cassproject.schema.general

/**
 * 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;
}

代码示例来源:origin: com.eduworks/cass.rollup

public void mutateAssertions(InquiryPacket ip, Array<String> listOfCompetencies, Callback0 success) {
    Array<String> keys = EcObject.keys(this.assertionProcessor.assertions);
    for (int keyIndex = 0; keyIndex < keys.$length(); keyIndex++) {
      Array<EcAssertion> ary = (Array) JSObjectAdapter.$get(this.assertionProcessor.assertions, keys.$get(keyIndex));
      for (int i = 0; i < ary.$length(); i++) {
        EcAssertion a = ary.$get(i);
        if (a.getAgent().toPem() == agent.toPem()) {
          a.confidence = a.confidence * multiplier;
          if (removeNoConfidence && a.confidence == 0.0)
            ary.splice(i--, 1);
        }
      }
    }
    success.$invoke();
  }
}

代码示例来源:origin: com.eduworks/cass.competency

for (int i = 0; i < competency.$length(); i++)
  if (competency.$get(i).equals(shortId) || competency.$get(i).equals(id))
    competency.splice(i, 1);
if ((relation == null || relation.$length() == 0) && (level == null || level.$length() == 0))
  if (success != null) {

代码示例来源:origin: com.eduworks/ebac.identity

d.signature.splice(i,1);
} else {
  i++;

相关文章