ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/util/ByteStack.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/util/ByteStack.java
Status
scanned
Type
file
Name
ByteStack.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
2971 (2.9 KB)
MD5
939c10009f5e98c76ae994cc91a323d8
SHA1
25787e766720266fd1237ca50925d022330b51a7
SHA256
5c46961b027de27fa5f2636b66afae573a4f96d8f89fe880589419eb48bb7e37
SHA512

      
    
SHA1_git
736d4ef2b7e6df638bc4e63a9f07a210acf34ed1
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ByteStack.java | 2.9 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.util; import java.util.Arrays; import java.util.NoSuchElementException; /** * The stack of byte values. This class is not synchronized and should not be * used by multiple threads concurrently. */ public final class ByteStack { private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; private int size; private byte[] array; /** * Creates a new empty instance. */ public ByteStack() { array = Utils.EMPTY_BYTES; } /** * Pushes an item onto the top of this stack. * * @param item * the item to push */ public void push(byte item) { int index = size; int oldLength = array.length; if (index >= oldLength) { grow(oldLength); } array[index] = item; size = index + 1; } /** * Removes the item at the top of this stack and returns that item. * * @return the item at the top of this stack * @throws NoSuchElementException * if stack is empty */ public byte pop() { int index = size - 1; if (index < 0) { throw new NoSuchElementException(); } size = index; return array[index]; } /** * Removes the item at the top of this stack and returns that item. * * @param defaultValue * value to return if stack is empty * @return the item at the top of this stack, or default value */ public int poll(int defaultValue) { int index = size - 1; if (index < 0) { return defaultValue; } size = index; return array[index]; } /** * Looks at the item at the top of this stack without removing it. * * @param defaultValue * value to return if stack is empty * @return the item at the top of this stack, or default value */ public int peek(int defaultValue) { int index = size - 1; if (index < 0) { return defaultValue; } return array[index]; } /** * Returns {@code true} if this stack is empty. * * @return {@code true} if this stack is empty */ public boolean isEmpty() { return size == 0; } /** * Returns the number of items in this stack. * * @return the number of items in this stack */ public int size() { return size; } private void grow(int length) { if (length == 0) { length = 0x10; } else if (length >= MAX_ARRAY_SIZE) { throw new OutOfMemoryError(); } else if ((length <<= 1) < 0) { length = MAX_ARRAY_SIZE; } array = Arrays.copyOf(array, length); } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
2.59
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220