java.util.Stack.lastElement()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(281)

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

Stack.lastElement介绍

暂无

代码示例

代码示例来源:origin: north2016/T-MVP

/**
   * 获取当前的Activity
   *
   * @return
   */
  public Activity getCurActivity() {
    return store.lastElement();
  }
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
   * 获取当前Activity(堆栈中最后一个压入的)
   */
  public Activity currentActivity() {
    try {
      Activity activity = activityStack.lastElement();
      return activity;
    } catch (Exception e) {
//            e.printStackTrace();
      return null;
    }
  }

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
 * 结束当前Activity(堆栈中最后一个压入的)
 */
public void finishActivity() {
  Activity activity = activityStack.lastElement();
  finishActivity(activity);
}

代码示例来源:origin: Sable/soot

public soot.jimple.Stmt previousStmt() {
 PatchingChain<Unit> o = (PatchingChain<Unit>)chains.lastElement();
 return (soot.jimple.Stmt)o.getLast();
}

代码示例来源:origin: igniterealtime/Smack

/**
 * Delete a directory with all subdirectories.
 * @param root
 */
public static void deleteDirectory(File root) {
  File[] currList;
  Stack<File> stack = new Stack<>();
  stack.push(root);
  while (!stack.isEmpty()) {
    if (stack.lastElement().isDirectory()) {
      currList = stack.lastElement().listFiles();
      if (currList != null && currList.length > 0) {
        for (File curr : currList) {
          stack.push(curr);
        }
      } else {
        stack.pop().delete();
      }
    } else {
      stack.pop().delete();
    }
  }
}

代码示例来源:origin: siyamed/android-shape-imageview

void endElement() {
    String localName = atts.getName();
    if (idRecordingStack.size() > 0){
      IdRecording ir = idRecordingStack.lastElement();
      ir.sb.append("</");
      ir.sb.append(localName);
      ir.sb.append(">");
      ir.level--;
      if (ir.level == 0) {
        String xml = ir.sb.toString();
        //Log.d(TAG, "Added element with id " + ir.id + " and content: " + xml);
        idXml.put(ir.id, xml);
        idRecordingStack.pop();
        if (idRecordingStack.size() > 0){
          idRecordingStack.lastElement().sb.append(xml);
        }
        Log.w(TAG, xml);
      }
    }
  }
}

代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android

/**
 * 获取倒数第二个 Activity
 *
 * @return
 */
@Nullable
public Activity getPenultimateActivity(Activity currentActivity) {
  Activity activity = null;
  try {
    if (mActivityStack.size() > 1) {
      activity = mActivityStack.get(mActivityStack.size() - 2);
      if (currentActivity.equals(activity)) {
        int index = mActivityStack.indexOf(currentActivity);
        if (index > 0) {
          // 处理内存泄漏或最后一个 Activity 正在 finishing 的情况
          activity = mActivityStack.get(index - 1);
        } else if (mActivityStack.size() == 2) {
          // 处理屏幕旋转后 mActivityStack 中顺序错乱
          activity = mActivityStack.lastElement();
        }
      }
    }
  } catch (Exception e) {
  }
  return activity;
}

代码示例来源:origin: siyamed/android-shape-imageview

void startElement() {
  String localName = atts.getName();
  String id = ParseUtil.getStringAttr("id", atts);
  if (id != null) {
    IdRecording ir = new IdRecording(id);
    idRecordingStack.push(ir);
  }
  if (idRecordingStack.size() > 0){
    IdRecording ir = idRecordingStack.lastElement();
    ir.level++;
    //appendElementString(ir.sb, atts.getNamespace(), localName, atts.getName(), atts);
    appendElementString(ir.sb, localName, atts);
  }
}

代码示例来源:origin: igniterealtime/Smack

/**
   * Recursively delete a directory and its contents.
   *
   * @param root root directory
   */
  public static void deleteDirectory(File root) {
    if (!root.exists()) {
      return;
    }
    File[] currList;
    Stack<File> stack = new Stack<>();
    stack.push(root);
    while (!stack.isEmpty()) {
      if (stack.lastElement().isDirectory()) {
        currList = stack.lastElement().listFiles();
        if (currList != null && currList.length > 0) {
          for (File curr : currList) {
            stack.push(curr);
          }
        } else {
          stack.pop().delete();
        }
      } else {
        stack.pop().delete();
      }
    }
  }
}

代码示例来源:origin: PrivacyApps/html-textview

NumberSpan span = new NumberSpan(indent, olNextIndex.lastElement() - 1);
if (lists.size() > 1) {
  indent = indent - span.getLeadingMargin(true);
NumberSpan numberSpan = new NumberSpan(indent, olNextIndex.lastElement() - 1);
end(output, Ol.class, false,
    new LeadingMarginSpan.Standard(listItemIndent * (lists.size() - 1)),

代码示例来源:origin: camunda/camunda-bpm-platform

public CompositeComponentDefinition getContainingComponent() {
  return (!this.containingComponents.isEmpty() ?
      (CompositeComponentDefinition) this.containingComponents.lastElement() : null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private String constructRecursionErrorMessage(Stack<Node> recursionNodes) {
 StringBuilder errorBuilder = new StringBuilder("Circular variable reference detected while parsing input [");
 for (Node stackNode : recursionNodes) {
  errorBuilder.append("${").append(variableNodeValue(stackNode)).append("}");
  if (recursionNodes.lastElement() != stackNode) {
   errorBuilder.append(" --> ");
  }
 }
 errorBuilder.append("]");
 return errorBuilder.toString();
}

代码示例来源:origin: apache/accumulo

@Override
public void startElement(String uri, String localName, String name, Attributes attributes) {
 if ("node".equals(name)) {
  String child = attributes.getValue("name");
  if (child == null)
   throw new RuntimeException("name attribute not set");
  String encoding = attributes.getValue("encoding");
  String value = attributes.getValue("value");
  if (value == null)
   value = "";
  String path = cwd.lastElement() + "/" + child;
  create(path, value, encoding);
  cwd.push(path);
 } else if ("dump".equals(name)) {
  String root = attributes.getValue("root");
  if (root.equals("/"))
   cwd.push("");
  else
   cwd.push(root);
  create(root, "", UTF_8.name());
 } else if ("ephemeral".equals(name)) {
  cwd.push("");
 }
}

代码示例来源:origin: ron190/jsql-injection

while (thisDiff != equalities.lastElement()) {
  thisDiff = pointer.previous();
  } else {
    thisDiff = equalities.lastElement();

代码示例来源:origin: ron190/jsql-injection

) {
  while (thisDiff != equalities.lastElement()) {
    thisDiff = pointer.previous();
    thisDiff = equalities.lastElement();
    while (thisDiff != pointer.previous()) {

代码示例来源:origin: myxh/CoolShopping

/**
 * 获取当前Activity
 */
public Activity getCurrentActivity() {
  Activity activity = activityStack.lastElement();
  return activity;
}

代码示例来源:origin: envyfan/AndroidReview

/**
 * 获取当前Activity(堆栈中最后一个压入的)
 */
public Activity currentActivity() {
  Activity activity = activityStack.lastElement();
  return activity;
}

代码示例来源:origin: huntermr/FastAndroid

/**
 * 获得当前的activity(即最上层)
 *
 * @return
 */
public Activity currentActivity() {
  Activity activity = null;
  if (!activityStack.empty())
    activity = activityStack.lastElement();
  return activity;
}

代码示例来源:origin: tony19/logback-android

private String constructRecursionErrorMessage(Stack<Node> recursionNodes) {
 StringBuilder errorBuilder = new StringBuilder("Circular variable reference detected while parsing input [");
 for (Node stackNode : recursionNodes) {
  errorBuilder.append("${").append(variableNodeValue(stackNode)).append("}");
  if (recursionNodes.lastElement() != stackNode) {
   errorBuilder.append(" --> ");
  }
 }
 errorBuilder.append("]");
 return errorBuilder.toString();
}

代码示例来源:origin: myxh/CoolShopping

/**
 * 结束当前Activity
 */
public void finishCurrentActivity() {
  Activity activity = activityStack.lastElement();
  finishActivity(activity);
}

相关文章