Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file modified .gradle/7.1.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/7.1.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.1.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file added .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file modified build/classes/java/main/com/oracle/arrays/Multidimensional.class
Binary file not shown.
Binary file modified build/classes/java/main/com/oracle/arrays/Unidimensional.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/classes/java/main/com/oracle/arrays/model/Posicion.class
Binary file not shown.
Binary file added build/classes/java/main/com/oracle/dao/CityDao.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
12 changes: 11 additions & 1 deletion src/main/java/com/oracle/arrays/impl/MultidimensionalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
public class MultidimensionalImpl implements Multidimensional {
@Override
public Posicion getPosition(String[][] datos, String dato) {
for(int i=0;i< datos.length;i++){
int j=0;
while(j<datos[i].length){
if(datos[i][j].equals(dato)){
return new Posicion(i,j);
}
j+=1;
}
}
return null;
}

@Override
public String getData(String[][] datos, Posicion posicion) {
return null;
return datos[posicion.getX()][posicion.getY()];
}
}

28 changes: 27 additions & 1 deletion src/main/java/com/oracle/arrays/impl/UnidimensionalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,36 @@
public class UnidimensionalImpl implements Unidimensional {
@Override
public void ordenamiento(int[] arr) {
boolean flag=false;
while(!flag){
flag=true;
for(int i=0;i<arr.length-1;i++){
if(arr[i]>arr[i+1]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puedes ver si hay una mejora de ordenamiento con respecto a tu actual solucion, hay algoritmos mas rapidos que puedes implementar incluso Arrays.sort()

int a=arr[i];
int b=arr[i+1];
arr[i+1]=a;
arr[i]=b;
flag=false;
}
}
}
}

@Override
public int[] ordenamientoReversa(int[] arr) {
return null;
boolean flag=false;
while(!flag){
flag=true;
for(int i=0;i<arr.length-1;i++){
if(arr[i]<arr[i+1]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lo mismo que el comentario anterior

int a=arr[i];
int b=arr[i+1];
arr[i+1]=a;
arr[i]=b;
flag=false;
}
}
}
return arr;
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/oracle/stream/CountriesAndCities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
import com.oracle.dao.CityDao;
import com.oracle.dao.CountryDao;
import com.oracle.dao.InMemoryWorldDao;
import com.oracle.domain.City;
import com.oracle.domain.Country;

import java.util.*;
import java.util.stream.Collectors;

public class CountriesAndCities {
private static final CountryDao countryDao = InMemoryWorldDao.getInstance();
private static final CityDao cityDao = InMemoryWorldDao.getInstance();

public static void main(String[] args) {
// Encontrar las ciudades mas pobladas en cada continente
Map<String, Optional<City>> ciudadesMasPobladas = cityDao.findAllCities().stream().collect(Collectors.groupingBy(city -> countryDao.findCountryByCode(city.getCountryCode()).getContinent(),Collectors.maxBy(Comparator.comparingInt(City::getPopulation))));
ciudadesMasPobladas.entrySet().forEach(System.out::println);
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/oracle/stream/StreamEjemplo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public static void main(String[] args) {
personList.add(new Person("Alisa", 7900, 26, "female", "New York"));

// Crear una nueva persona y agregarla a la lista
List<Person> personList2 = personList.stream().map().collect(Collectors.toList());
//List<Person> personList2 = personList.stream().map().collect(Collectors.toList());
// Convertir km a millas
List<Person> personList3 = personList2.stream().map().collect(Collectors.toList());
List<Person> personList3 = personList.stream().map(person -> {person.setKmPerYear((int)(person.getKmPerYear()*0.621371)); return person;}).peek(person -> System.out.println(person.getKmPerYear())).collect(Collectors.toList());
}
}

Expand All @@ -29,6 +29,14 @@ class Person {
private String genre;
private String city;

public int getKmPerYear() {
return kmPerYear;
}

public void setKmPerYear(int kmPerYear) {
this.kmPerYear = kmPerYear;
}

public Person(String name, int kmPerYear, int age, String genre, String city) {
this.name = name;
this.kmPerYear = kmPerYear;
Expand Down