hashData method
Implementation
bool hashData(List datas) {
int count_valid = 0;
int count_data_same = 0;
void countValids(List data_origins) {
for (var i = 0; i < data_origins.length; i++) {
dynamic value = data_origins[i];
if (value is Map) {
count_valid++;
} else if (value is List) {
countValids(value);
} else {
count_valid++;
}
}
}
for (var i = 0; i < datas.length; i++) {
dynamic value = datas[i];
if (value is Map) {
count_valid++;
} else if (value is List) {
countValids(value);
} else {
count_valid++;
}
}
void countSame(List data_origin, List data_old) {
int count_length = data_old.length;
for (var i = 0; i < data_origin.length; i++) {
if (i >= count_length) {
continue;
}
dynamic value = datas[i];
dynamic value_origin = data_origin[i];
if (value is RegExp) {
if (value.hashData(value_origin)) {
count_data_same++;
}
} else if (value is Map) {
if (value_origin is Map) {
if (value_origin.hashData(value)) {
count_data_same++;
}
}
} else if (value is List) {
if (value_origin is List) {
countSame(value_origin, value);
}
} else {
if (value_origin == value) {
count_data_same++;
}
}
}
}
int count_length = length;
for (var i = 0; i < datas.length; i++) {
if (i >= count_length) {
continue;
}
dynamic value = datas[i];
dynamic value_origin = this[i];
if (value is RegExp) {
if (value.hashData(value_origin)) {
count_data_same++;
}
} else if (value is Map) {
if (value_origin is Map) {
if (value_origin.hashData(value)) {
count_data_same++;
}
}
} else if (value is List) {
if (value_origin is List) {
countSame(value_origin, value);
}
} else {
if (value_origin == value) {
count_data_same++;
}
}
}
if (count_valid == 0) {
return false;
}
return (count_valid == count_data_same);
}