Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kenri89/PROYECTO_UTP_AED_1_1/llms.txt
Use this file to discover all available pages before exploring further.
ArregloCursos in estructuras.ArregloCursos is a dynamic array backed by a plain Curso[]. The initial capacity is 100 elements. When the logical size contador reaches the physical array length, a redimensionar() call creates a new array at twice the capacity and copies all elements using System.arraycopy. The class is the primary data source for Apache POI Excel export, and its obtener(int indice) method enables O(1) random access that the linked structures cannot provide.
Internal State
The class maintains two private fields:| Field | Type | Description |
|---|---|---|
cursos | Curso[] | Backing array, starts at length 100 |
contador | int | Logical element count (next free index) |
contador - 1 are populated; positions contador and above are null.
Public API
insertar(Curso curso)
Appends the course at index
contador. If contador >= cursos.length, redimensionar() is called first to double the backing array. Amortised complexity O(1).obtener(int indice)
Returns the
Curso at the given index with a bounds check against contador. Returns null for an out-of-range index rather than throwing. Complexity O(1).getContador()
Returns the logical size of the array — the number of currently stored courses. O(1). Used by iteration loops:
for (int i = 0; i < arreglo.getContador(); i++).obtenerCursos()
Collects all non-null elements from index 0 to
contador - 1 into a List<Curso> and returns it. This is the method called by ExportadorExcel to stream course data into an Apache POI workbook. Complexity O(n).buscar(String codigo)
Linear scan from index 0 to
contador - 1, comparing each element’s getCodigo() with equalsIgnoreCase. Returns the first matching Curso or null. Complexity O(n).eliminarPorCodigo(String codigo)
Finds the target element by linear scan, then shifts all subsequent elements one position to the left to close the gap, nulls the last occupied slot, and decrements
contador. Returns true if removed, false if not found. Complexity O(n).actualizarCurso(String codigo, Curso actualizado)
Locates the element by code with a linear scan and replaces it in-place with the
actualizado reference. The slot index does not change. Returns true on success. Complexity O(n).Resize Algorithm
When the backing array is full,redimensionar() allocates a new array of double the current length and uses System.arraycopy for an efficient block copy.
ExportadorExcel Integration
ExportadorExcel.exportarCursos(ArregloCursos arreglo, File destino) calls arreglo.obtenerCursos() to obtain a List<Curso> and then iterates it with Apache POI to write each course as a row in an .xlsx workbook. ArregloCursos is the sole source for this export; ListaCursos and MatrizSemestres are not used by the exporter.
Relationship with ListaCursos
ListaCursos is a parallel singly-linked list that holds references to the same Curso objects stored in ArregloCursos. The two structures do not duplicate data — they share object references. ListaCursos is used for combo-box traversal via its recorrer(Consumer<Curso>) method and for enrollment lookups via buscar(String codigo), while ArregloCursos serves iteration-by-index and Excel export.