Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 1.0/2.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему  
Старый 25.12.2007, 10:54
f3ath вне форума Посмотреть профиль Отправить личное сообщение для f3ath Найти все сообщения от f3ath
  № 19  
f3ath

Регистрация: Dec 2007
Сообщений: 8
Итератор как в php5

Интерфейс:
Код:
interface Iterator // this is interface actually, identical to PHP5 iterator
{
	// Returns the current value
	public function current();
 
	// Returns the current key
	public function key();
 
	// Moves the internal pointer to the next element
	public function next():Void
 
	// Moves the internal pointer to the first element
	public function rewind():Void;
 
	// If the current element is valid (boolean)
	public function valid():Boolean;
}
Итератор для массива
Код:
class ArrayIterator implements Iterator
{
	private var p:Number;
	private var a:Array;
	
	public function ArrayIterator(arr)
	{
		this.a = arr;
		this.p = 0;
	}
	
	// Returns the current value
	public function current()
	{
		return a[p];
	}
	
 
	// Returns the current key
	public function key()
	{
		return p;
	}
 
	// Moves the internal pointer to the next element
	public function next():Void
	{
		this.p++;
	}

	// Moves the internal pointer to the previuos element
	public function prev():Void
	{
		this.p--;
	}
	
 
	// Moves the internal pointer to the first element
	public function rewind():Void
	{
		this.p = 0;
	}

	// Moves the internal pointer to the last element
	public function ff():Void
	{
		this.p = (this.a.length - 1) ;
	}
 
	// If the current element is valid (boolean)
	public function valid():Boolean
	{
		return Boolean(this.p < this.a.length);
	}
}

Создать новую тему   Часовой пояс GMT +4, время: 23:27.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


Часовой пояс GMT +4, время: 23:27.


Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.