Forum > Spanish

iteradoras en pascal

(1/3) > >>

zelda16bit:
Me gustaria saber si hay iteradores para recorrer los contenedores de la biblioteca generic.colletion o fgl,algo parecido a lo que tiene c++.

JdeHaan:
The translation says:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---I would like to know if there are iterators to traverse the containers of the generics.collections or fgl library, something similar to what c++ has.
Short answer: yes, for each container type there are iterators (or enumerators).
example


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$mode delphi} uses Generics.Collections; var   list: TList<String>;  item: String;begin  list := TList<String>.Create;  list.add('hello');  list.add('world');  for item in list do    writeln(item);  list.Free;end. 

zelda16bit:
Yo me refiero ha algo mas especifico como esto.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    std::list<int> lista{10,11,12,13,14,15};     std::list<int>::iterator iterador{ lista.begin() };     while(iterador != lista.end()){        std::cout<<*iterador<<" ";        ++iterador;    } 

TRon:
Sorry, no Espanol.


--- Quote from: zelda16bit on February 21, 2023, 01:42:30 pm ---No veo el uso de iteradoresmsolo veo

--- End quote ---
which translates for me to:

--- Quote ---I don't see the use of iterator glaze only see

--- End quote ---


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$mode delphi} uses Generics.Collections; var  list: TList<String>;  item: String;begin  list := TList<String>.Create;  list.add('hello');  list.add('world');  for item in list do    writeln(item);  list.Free;end. I have highlighted the iterator part.

TRon:

--- Quote from: zelda16bit on February 21, 2023, 01:42:30 pm ---Yo me refiero ha algo mas especifico como esto.

--- End quote ---

Which translates for me to:

--- Quote ---I mean something more specific like this.

--- End quote ---

The following example is using mode OBJFPC instead of mode DELPHI and should behave similar as you c-code (the enumarator is again highlighted).

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program test; {$mode objfpc} uses  generics.Collections; type  TIntegerList = specialize TList<integer>;var  integers : array of integer = (10,11,12,13,14,15);  list: TIntegerList;  item: integer;begin  list := TIntegerList.Create;   // quickly add integer items to list  for item in integers    do List.Add(item);   // iterate over list and display each item  for item in list    do writeln(item);   list.Free;end. 

Navigation

[0] Message Index

[#] Next page

Go to full version