Logo Search packages:      
Sourcecode: kaya version File versions  Download package


#ifndef _ARRAY_H
#define _ARRAY_H

    Kaya run-time system
    Copyright (C) 2004, 2005 Edwin Brady

    This file is distributed under the terms of the GNU Lesser General
    Public Licence. See COPYING for licence.

#include <pthread.h>
#include <gc/gc_cpp.h>

class Value;

/** Chunks of data inside arrays. 
    We can't move arrays around if they grow, as there might be references 
    into them, so we store them as a linked list of chunks. */
00021 struct chunk : public gc {
    Value** data;
    int size;
    chunk* next;

class Array : public gc_cleanup
    Array(int size=0);
    void push_back(Value* v);
    Value* lookup(int i);
    inline int size() { return m_size; }
    Array* copy();
    void resize(int i);
    Value* shift();

    /// Make sure there's enough space for at least i things.
    void expectedSize(int i);

    bool eq(Array* x);
    int cmp(Array* x);

    int m_alloc;
    int m_size;
    chunk* m_first;


Generated by  Doxygen 1.6.0   Back to index