Changeset 5844


Ignore:
Timestamp:
02/16/04 00:46:36 (17 years ago)
Author:
piso
Message:

adjustArray(): support initialElement.

Location:
trunk/j/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/LispString.java

    r5825 r5844  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: LispString.java,v 1.79 2004-02-14 18:52:25 piso Exp $
     5 * $Id: LispString.java,v 1.80 2004-02-16 00:46:22 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    312312    }
    313313
    314     public LispString adjustArray(int size)
     314    public LispString adjustArray(int size, LispObject initialElement)
     315        throws ConditionThrowable
    315316    {
    316317        if (chars.length != size) {
     
    318319            System.arraycopy(chars, 0, newArray, 0,
    319320                             Math.min(chars.length, size));
     321            if (size > chars.length) {
     322                final char c;
     323                if (initialElement != NIL)
     324                    c = LispCharacter.getValue(initialElement);
     325                else
     326                    c = 0;
     327                for (int i = chars.length; i < size; i++)
     328                    newArray[i] = c;
     329            }
    320330            chars = newArray;
    321331        }
  • trunk/j/src/org/armedbear/lisp/Vector.java

    r5755 r5844  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Vector.java,v 1.30 2004-02-11 00:11:39 piso Exp $
     5 * $Id: Vector.java,v 1.31 2004-02-16 00:46:36 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    8282    }
    8383
    84     public Vector adjustArray(int size)
     84    public Vector adjustArray(int size, LispObject initialElement)
    8585    {
    8686        if (elements.length != size) {
     
    8888            System.arraycopy(elements, 0, newArray, 0,
    8989                             Math.min(elements.length, size));
     90            if (size > elements.length) {
     91                for (int i = elements.length; i < size; i++)
     92                    newArray[i] = initialElement;
     93            }
    9094            elements = newArray;
    9195            capacity = size;
Note: See TracChangeset for help on using the changeset viewer.