;;; Lisplab, vector1-generic.lisp ;;; Generic vector implementaion ;;; Copyright (C) 2009 Joern Inge Vestgaarden ;;; ;;; This program 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 of the License, or ;;; (at your option) any later version. ;;; ;;; This program 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 this program; if not, write to the Free Software Foundation, Inc., ;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (in-package :lisplab) ;;; General (defmethod print-object ((v vector-base) stream) (print-unreadable-object (v stream :type t :identity t) (dotimes (i (min (size v) *lisplab-print-size*)) (format stream "~a " (vref v i))))) (defmethod vector-p ((x vector-base)) t) (defmethod rank ((x vector-base)) 1) (defmethod dim ((x vector-base) &optional d) (if d (ecase d (0 (size x))) (list (size x)))) ;;; Untyped vectors (defmethod vref ((vector vector-any) idx) (aref (slot-value vector 'store) idx)) (defmethod (setf vref) (value (vector vector-any) idx) (setf (aref (slot-value vector 'store) idx) value))