Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/xslt/base/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  txStack.h   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef txStack_h___
#define txStack_h___

#include "nsTArray.h"

class txStack : private nsTArray<void*> {
 public:
  /**
   * Returns the specified object from the top of this stack,
   * without removing it from the stack.
   *
   * @return a pointer to the object that is the top of this stack.
   */

  inline void* peek() {
    NS_ASSERTION(!isEmpty(), "peeking at empty stack");
    return !isEmpty() ? ElementAt(Length() - 1) : nullptr;
  }

  /**
   * Adds the specified object to the top of this stack.
   *
   * @param obj a pointer to the object that is to be added to the
   * top of this stack.
   */

  inline void push(void* aObject) { AppendElement(aObject); }

  /**
   * Removes and returns the specified object from the top of this
   * stack.
   *
   * @return a pointer to the object that was the top of this stack.
   */

  inline void* pop() {
    void* object = nullptr;
    NS_ASSERTION(!isEmpty(), "popping from empty stack");
    if (!isEmpty()) {
      object = PopLastElement();
    }
    return object;
  }

  /**
   * Returns true if there are no objects in the stack.
   *
   * @return true if there are no objects in the stack.
   */

  inline bool isEmpty() { return IsEmpty(); }

  /**
   * Returns the number of elements in the Stack.
   *
   * @return the number of elements in the Stack.
   */

  inline int32_t size() { return Length(); }

 private:
  friend class txStackIterator;
};

class txStackIterator {
 public:
  /**
   * Creates an iterator for the given stack.
   *
   * @param aStack the stack to create an iterator for.
   */

  inline explicit txStackIterator(txStack* aStack)
      : mStack(aStack), mPosition(0) {}

  /**
   * Returns true if there is more objects on the stack.
   *
   * @return .
   */

  inline bool hasNext() { return (mPosition < mStack->Length()); }

  /**
   * Returns the next object pointer from the stack.
   *
   * @return .
   */

  inline void* next() {
    if (mPosition == mStack->Length()) {
      return nullptr;
    }
    return mStack->ElementAt(mPosition++);
  }

 private:
  txStack* mStack;
  uint32_t mPosition;
};

#endif /* txStack_h___ */

Messung V0.5
C=90 H=100 G=95

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.