vectors.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* classes: h_files */
  2. #ifndef SCM_VECTORS_H
  3. #define SCM_VECTORS_H
  4. /* Copyright (C) 1995,1996,1998,2000,2001,2002,2004,2005, 2006, 2008, 2009, 2011, 2014 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. SCM_API SCM scm_vector_p (SCM x);
  23. SCM_API SCM scm_vector_length (SCM v);
  24. SCM_API SCM scm_vector (SCM l);
  25. SCM_API SCM scm_vector_ref (SCM v, SCM k);
  26. SCM_API SCM scm_vector_set_x (SCM v, SCM k, SCM obj);
  27. SCM_API SCM scm_make_vector (SCM k, SCM fill);
  28. SCM_API SCM scm_vector_to_list (SCM v);
  29. SCM_API SCM scm_vector_fill_x (SCM v, SCM fill_x);
  30. SCM_API SCM scm_vector_move_left_x (SCM vec1, SCM start1, SCM end1,
  31. SCM vec2, SCM start2);
  32. SCM_API SCM scm_vector_move_right_x (SCM vec1, SCM start1, SCM end1,
  33. SCM vec2, SCM start2);
  34. SCM_API SCM scm_vector_copy (SCM vec);
  35. SCM_API int scm_is_vector (SCM obj);
  36. SCM_API int scm_is_simple_vector (SCM obj);
  37. SCM_API SCM scm_c_make_vector (size_t len, SCM fill);
  38. SCM_API size_t scm_c_vector_length (SCM vec);
  39. SCM_API SCM scm_c_vector_ref (SCM vec, size_t k);
  40. SCM_API void scm_c_vector_set_x (SCM vec, size_t k, SCM obj);
  41. SCM_API const SCM *scm_vector_elements (SCM vec,
  42. scm_t_array_handle *h,
  43. size_t *lenp, ssize_t *incp);
  44. SCM_API SCM *scm_vector_writable_elements (SCM vec,
  45. scm_t_array_handle *h,
  46. size_t *lenp, ssize_t *incp);
  47. /* Fast, non-checking accessors for simple vectors.
  48. */
  49. #define SCM_SIMPLE_VECTOR_LENGTH(x) SCM_I_VECTOR_LENGTH(x)
  50. #define SCM_SIMPLE_VECTOR_REF(x,idx) ((SCM_I_VECTOR_ELTS(x))[idx])
  51. #define SCM_SIMPLE_VECTOR_SET(x,idx,val) ((SCM_I_VECTOR_WELTS(x))[idx]=(val))
  52. /* Internals */
  53. #define SCM_I_IS_VECTOR(x) (SCM_HAS_TYP7 (x, scm_tc7_vector))
  54. #define SCM_I_VECTOR_ELTS(x) ((const SCM *) SCM_I_VECTOR_WELTS (x))
  55. #define SCM_I_VECTOR_WELTS(x) (SCM_CELL_OBJECT_LOC (x, 1))
  56. #define SCM_I_VECTOR_LENGTH(x) (((size_t) SCM_CELL_WORD_0 (x)) >> 8)
  57. SCM_INTERNAL SCM scm_i_vector_equal_p (SCM x, SCM y);
  58. SCM_INTERNAL void scm_init_vectors (void);
  59. #endif /* SCM_VECTORS_H */
  60. /*
  61. Local Variables:
  62. c-file-style: "gnu"
  63. End:
  64. */