/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/utils/stack.vala

  • Committer: Gustav Hartvigsson
  • Date: 2022-05-30 18:46:35 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20220530184635-d8k8pofyyifu017d
Woops.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * The contects of this file is in the Public Domain.
3
 
 *
4
 
 * Created by Gustav Hartivgsson.
5
 
 */
6
 
 
7
 
namespace Vee {
 
1
namespace Utils {
 
2
  [CCode (cname = "VStack", cprefix = "v_stack_")]
8
3
  public class Stack <T> {
9
 
    private static int32 step_size = 11;
 
4
    private static int step_size = 11;
10
5
    private T[] stack;
11
 
    private int32 pntr;
 
6
    private int pntr;
12
7
    public size_t elements {get {return pntr + 1;}}
13
8
    private size_t size;
14
9
    
15
 
    
 
10
    [CCode (has_target = true)]
16
11
    public delegate bool ForEachFunc<V> (V item);
17
12
 
18
13
    public Stack (size_t size = 23) {
31
26
 
32
27
    public T pop () {
33
28
      if (this.pntr < 0) {
34
 
        info ("Trying to pop value from empty Stack:\n" +
 
29
        info ("Tryinng to pop value from empty Stack:\n" +
35
30
                 "\treturning NULL.");
36
31
        return null;
37
32
      }