WIP
parent
04f02fbb93
commit
06c8e76f99
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Yavsc.Abstract.IT
|
||||||
|
{
|
||||||
|
|
||||||
|
public class CharArray : List<char>, IEnumerable<char>, IList<char>
|
||||||
|
{
|
||||||
|
|
||||||
|
public CharArray (char [] charArray) : base (charArray)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public CharArray (IList<char> word): base(word) {
|
||||||
|
|
||||||
|
}
|
||||||
|
public CharArray (IEnumerable<char> word): base(word) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<char> Aggregate(char other)
|
||||||
|
{
|
||||||
|
this.Add(other);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CodeFromChars : List<CharArray>, ICode<char>
|
||||||
|
{
|
||||||
|
public void AddLetter(IEnumerable<char> letter)
|
||||||
|
{
|
||||||
|
var candide = new CharArray(letter);
|
||||||
|
|
||||||
|
// TODO build new denied letters: compute the automate
|
||||||
|
|
||||||
|
Add(candide);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator<IEnumerable<char>> IEnumerable<IEnumerable<char>>.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,22 +1,24 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Yavsc
|
namespace Yavsc.Abstract.IT
|
||||||
{
|
{
|
||||||
public interface ILetter<T> : IEqualityComparer<T> {
|
// un code est, parmis les ensembles de suites de signes,
|
||||||
}
|
// ceux qui n'ont qu'une seule suite de suites pouvant représenter toute suite de suite de signes
|
||||||
public interface IWord<TLetter> where TLetter : ILetter<TLetter>
|
|
||||||
{
|
|
||||||
IWord<TLetter> Aggregate(TLetter other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ICode<TLetter> : IEnumerable<TLetter> where TLetter : ILetter<TLetter>
|
public interface ICode<TSign> : IEnumerable<IEnumerable<TSign>>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks that (b!=c) => a.b != a.c
|
/// Checks false that a letter list combinaison correspond to another one
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool Validate();
|
bool Validate();
|
||||||
|
|
||||||
IWord<TLetter> CreateWord(TLetter letter);
|
/// <summary>
|
||||||
|
/// Defines a new letter in this code,
|
||||||
|
/// as an enumerable of <c>TLetter</c>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="letter"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
void AddLetter(IEnumerable<TSign> letter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Yavsc.Models.IT.Modeling
|
|
||||||
{
|
|
||||||
public abstract class Code<TLetter> : ICode<TLetter> where TLetter : ILetter<TLetter>
|
|
||||||
{
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// !a Count^3 task len
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Validate()
|
|
||||||
{
|
|
||||||
foreach (var letter in this) {
|
|
||||||
var word = this.CreateWord(letter);
|
|
||||||
foreach (var other in this) {
|
|
||||||
IWord<TLetter> first = word.Aggregate(other);
|
|
||||||
foreach (var tierce in this)
|
|
||||||
{
|
|
||||||
var otherword = word.Aggregate(tierce);
|
|
||||||
if (first.Equals(otherword))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract IEnumerator<TLetter> GetEnumerator();
|
|
||||||
|
|
||||||
public abstract IWord<TLetter> CreateWord(TLetter letter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
namespace Yavsc.Models.IT.Modeling
|
|
||||||
{
|
|
||||||
public abstract class Letter<T> : ILetter<T>
|
|
||||||
{
|
|
||||||
public abstract bool Equals(T x, T y);
|
|
||||||
|
|
||||||
public int GetHashCode(T obj)
|
|
||||||
{
|
|
||||||
return obj.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue