示例#1
0
        public bool Add(DIDATuple didaAdd)
        {
            Type typeFirstElem = didaAdd.GetTupleList()[0].GetType();

            if (tupleSpace.ContainsKey(typeFirstElem.ToString()))
            {
                //UPDATE AO DICIONARIO
                List <DIDATuple> oldDidaList = new List <DIDATuple>();
                bool             result      = tupleSpace.TryGetValue(typeFirstElem.ToString(), out oldDidaList);

                if (result)
                {
                    oldDidaList.Add(didaAdd);
                }
                size++;
            }
            else
            {
                //Adicionar ao Dicionario
                List <DIDATuple> newDidaList = new List <DIDATuple>();
                newDidaList.Add(didaAdd);
                tupleSpace.Add(typeFirstElem.ToString(), newDidaList);
                size++;
            }


            return(true);
        }
示例#2
0
        public void PrintTuple(DIDATuple didatuple)
        {
            int tuplesize = didatuple.GetTupleList().Count;

            for (int i = 0; i < tuplesize; i++)
            {
                if (i == tuplesize - 1)
                {
                    Console.Write(didatuple.GetTupleList()[i]);
                    Console.WriteLine("");
                }
                else
                {
                    Console.Write(didatuple.GetTupleList()[i]);
                    Console.Write(",");
                }
            }
        }
示例#3
0
        public bool Remove(DIDATuple didaTake)
        {
            Type             typeFirstElem = didaTake.GetTupleList()[0].GetType();
            List <DIDATuple> listToReturn  = new List <DIDATuple>();

            if (tupleSpace.ContainsKey(typeFirstElem.ToString()))
            {
                listToReturn = tupleSpace[typeFirstElem.ToString()];
                tupleSpace.Remove(typeFirstElem.ToString());
                listToReturn.Remove(didaTake);

                tupleSpace.Add(typeFirstElem.ToString(), listToReturn);


                return(true);
            }


            return(false);
        }
示例#4
0
        public DIDATuple Read(DIDATuple didaRead)
        {
            Type typeFirstElem = didaRead.GetTupleList()[0].GetType();

            if (tupleSpace.ContainsKey(typeFirstElem.ToString()))
            {
                List <DIDATuple> didaList = new List <DIDATuple>();
                bool             result   = tupleSpace.TryGetValue(typeFirstElem.ToString(), out didaList);

                if (result)
                {
                    foreach (DIDATuple didaTuple in didaList)
                    {
                        if (didaTuple.CompareParams(didaRead))
                        {
                            return(didaTuple);
                        }
                    }
                }
            }
            return(null);
        }
示例#5
0
        public List <IDIDATuple> Take(DIDATuple didaTake)
        {
            Type typeFirstElem             = didaTake.GetTupleList()[0].GetType();
            List <IDIDATuple> listToReturn = new List <IDIDATuple>();

            if (tupleSpace.ContainsKey(typeFirstElem.ToString()))
            {
                List <DIDATuple> didaList = new List <DIDATuple>();
                bool             result   = tupleSpace.TryGetValue(typeFirstElem.ToString(), out didaList);

                if (result)
                {
                    foreach (DIDATuple didaTuple in didaList)
                    {
                        if (didaTuple.CompareParams(didaTake))
                        {
                            listToReturn.Add(didaTake);
                        }
                    }
                }
            }
            return(listToReturn);
        }