view scripts/plot/__uiobject_grow_list__.in @ 6257:44c91c5dfe1d

[project @ 2007-01-30 19:16:52 by jwe]
author jwe
date Tue, 30 Jan 2007 19:16:55 +0000
parents
children a7a2f1596b4b
line wrap: on
line source

## Copyright (C) 2005 John W. Eaton
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, write to the Free
## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.

## -*- texinfo -*-
## @deftypefn {Function File} {} __uiobject_grow_list__ ()
## Create or increase the size of @code{__uiobject_list__}.
## @end deftypefn

## Author: jwe

function __uiobject_grow_list__ ()

  __uiobject_globals__;

  if (nargin == 0)
    static grow_size = 100;
    curr_size = length (__uiobject_list__);
    new_size = curr_size + grow_size;
    __uiobject_list__(new_size).next = 0;
    __uiobject_list__(new_size).in_use = false;
    __uiobject_list__(new_size).handle = NaN;
    __uiobject_list__(new_size).object = NaN;
    if (curr_size)
      __uiobject_list__(curr_size).next = curr_size+1;
      __uiobject_list__(curr_size).in_use = false;
      __uiobject_list__(curr_size).handle = NaN;
      __uiobject_list__(curr_size).object = NaN;
    endif
    for i = new_size-1:-1:curr_size+1
      __uiobject_list__(i).next = i+1;
      __uiobject_list__(i).in_use = false;
      __uiobject_list__(i).handle = NaN;
      __uiobject_list__(i).object = NaN;
    endfor
    __uiobject_head__ = curr_size+1;
  else
    print_usage ();
  endif
endfunction