Exemplo n.º 1
0
        public void ReadFromVectorsEfficiencyComparison(FdoCache fcTLP)
        {
            LangProject lp = fcTLP.LangProject;

            //bad
            for (int i = 1; i < lp.OverlaysOC.Count; i++)                      // must create an FdoOwnColVector each time!
            {
                CmOverlay o = new CmOverlay(fcTLP, lp.OverlaysOC.hvoArray[i]); // must create an FdoOwnColVector each time!
                Console.WriteLine(o.Name);
            }

            //better
            int[] hvos = lp.OverlaysOC.hvoArray;                       // get the vector just once
            for (int i = 1; i < hvos.Length; i++)
            {
                CmOverlay o = new CmOverlay(fcTLP, hvos[i]);
                Console.WriteLine(o.Name);
            }

            //best: get vector just once, and all of the overlays will be cached at once
            foreach (CmOverlay o in lp.OverlaysOC)
            {
                Console.WriteLine(o.Name);
            }
        }
Exemplo n.º 2
0
        public void ModifyVectors(LangProject lp)
        {
            //add a new item to an owned sequence attribute
            CmAnthroItem a = (CmAnthroItem)lp.AnthroListOA.PossibilitiesOS.Append(new CmAnthroItem());

            //add a new item to an owned collection attribute
            CmOverlay overlay = (CmOverlay)lp.OverlaysOC.Add(new CmOverlay());

            //add a new item to a reference collection attribute
            CmPossibility position = (CmPossibility)lp.PositionsOA.PossibilitiesOS [0];
            CmPerson      person   = (CmPerson)lp.PeopleOA.PossibilitiesOS[0];

            person.PositionsRC.Add(position);

            //move the last item in a sequence to the beginning
            FdoOwnSeqVector positions = lp.PositionsOA.PossibilitiesOS;

            position = (CmPossibility)positions[positions.Count - 1];
            positions.InsertAt(position, 0);

            //do the same, without instantiating the object we're moving
            int hvo = positions.hvoArray[positions.Count - 1];

            positions.InsertAt(hvo, 0);
        }
Exemplo n.º 3
0
			public void ReadFromVectorsEfficiencyComparison(FdoCache fcTLP)
			{
				LangProject lp = fcTLP.LangProject;

				//bad
				for(int i = 1; i< lp.OverlaysOC.Count; i++) // must create an FdoOwnColVector each time!
				{
					CmOverlay o = new CmOverlay(fcTLP,lp.OverlaysOC.hvoArray[i]);	// must create an FdoOwnColVector each time!
					Console.WriteLine(o.Name);
				}

				//better
				int[] hvos  = lp.OverlaysOC.hvoArray;  // get the vector just once
				for(int i = 1; i<hvos.Length; i++)
				{
					CmOverlay o = new CmOverlay(fcTLP,hvos[i]);
					Console.WriteLine(o.Name);
				}

				//best: get vector just once, and all of the overlays will be cached at once
				foreach(CmOverlay o in lp.OverlaysOC)
				{
					Console.WriteLine(o.Name);
				}
			}