メニュー


更新履歴

取得中です。

アクセス数 -
Today -
Yesterday -


メニューを編集

javascript plugin Error : このプラグインで利用できない命令または文字列が入っています。
※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

Array


Object > Array

Ruby C
Array rb_cArray
Array.new rb_ary_new()
Array.new(size) rb_ary_new2(len)
rb_ary_new3(n, va_alist)
rb_ary_new4(n, elts)
Array#[] rb_ary_aref(argc, argv, ary)
Array#[](nth) rb_ary_entry(ary, long offset)
Array#[]=(nth, val) rb_ary_store(ary, long idx, val)
Array#+ rb_ary_plus(x, y)
Array#<< rb_ary_push(ary, item)
Array#<=> rb_ary_cmp(ary1, ary2)
Array#assoc rb_ary_assoc(ary, key)
Array#at rb_ary_entry(ary, long offset)
Array#clear rb_ary_clear(ary)
Array#concat rb_ary_concat(x, y)
Array#delete rb_ary_delete(ary, item)
Array#delete_at rb_ary_delete_at(ary, long pos)
Array#dup rb_ary_dup(ary)
Array#each rb_ary_each(ary)
Array#freeze rb_ary_freeze(ary)
Array#include? rb_ary_includes(ary, item)
Array#join rb_ary_join(ary, sep)
Array#pop rb_ary_pop(ary)
Array#rassoc rb_ary_rassoc(ary, value)
Array#reverse! rb_ary_reverse(ary)
Array#shift rb_ary_shift(ary)
Array#slice rb_ary_aref(argc, argv, ary)
Array#sort rb_ary_sort(ary)
Array#sort! rb_ary_sort_bang(ary)
Array#to_s rb_ary_to_s(ary)
Array#unshift rb_ary_unshift(ary, item)
obj.to_ary rb_ary_to_ary(obj)
rb_values_at(obj, olen, argc, argv, func)

static VALUE
ary_alloc(klass)
    VALUE klass;
{
    NEWOBJ(ary, struct RArray);
    OBJSETUP(ary, klass, T_ARRAY);
 
    ary->len = 0;
    ary->ptr = 0;
    ary->aux.capa = 0;
 
    return (VALUE)ary;
}
 

static VALUE
ary_new(klass, len)
    VALUE klass;
    long len;
{
    VALUE ary = ary_alloc(klass);
 
    if (len < 0) {
	rb_raise(rb_eArgError, "negative array size (or size too big)");
    }
    if (len > ARY_MAX_SIZE) {
	rb_raise(rb_eArgError, "array size too big");
    }
    if (len == 0) len++;
    RARRAY(ary)->ptr = ALLOC_N(VALUE, len);
    RARRAY(ary)->aux.capa = len;
 
    return ary;
}
 

VALUE
rb_ary_new2(len)
    long len;
{
    return ary_new(rb_cArray, len);
}
 

VALUE
rb_ary_new()
{
    return rb_ary_new2(ARY_DEFAULT_SIZE);
}
 

VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_ary_new3(long n, ...)
#else
rb_ary_new3(n, va_alist)
    long n;
    va_dcl
#endif
{
    va_list ar;
    VALUE ary;
    long i;
 
    ary = rb_ary_new2(n);
 
    va_init_list(ar, n);
    for (i=0; i<n; i++) {
	RARRAY(ary)->ptr[i] = va_arg(ar, VALUE);
    }
    va_end(ar);
 
    RARRAY(ary)->len = n;
    return ary;
}
 

VALUE
rb_ary_new4(n, elts)
    long n;
    const VALUE *elts;
{
    VALUE ary;
 
    ary = rb_ary_new2(n);
    if (n > 0 && elts) {
	MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
    }
 
    /* This assignment to len will be moved to the above "if" block in Ruby 1.9 */
    RARRAY(ary)->len = n;
 
    return ary;
}
 
|新しいページ|検索|ページ一覧|RSS|@ウィキご利用ガイド | 管理者にお問合せ
|ログイン|