예제 #1
0
        public void AppendMorphoFormEndings(BaseMorphoFormNative other)
        {
            Debug.Assert(_morphoFormEndings[0] == other._morphoFormEndings[0],
                         "_MorphoFormEndings[ 0 ] != baseMorphoForms._MorphoFormEndings[ 0 ]");

            //select longest array of morpho-form-endings
            char *[] first, second;
            if (_morphoFormEndings.Length < other._morphoFormEndings.Length)
            {
                first  = other._morphoFormEndings;
                second = _morphoFormEndings;
            }
            else
            {
                first  = _morphoFormEndings;
                second = other._morphoFormEndings;
            }

            fixed(char **morphoFormEndingsBase = first)
            {
                for (int i = 0, len = first.Length; i < len; i++)
                {
                    tempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i)));
                }
            }

            //store curreent count in 'tempBufferHS'
            var count = tempBufferHS.Count;

            fixed(char **morphoFormEndingsBase = second)
            {
                for (int i = 0, len = second.Length; i < len; i++)
                {
                    tempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i)));
                }
            }

            //if count of 'tempBufferHS' not changed, then [_MorphoFormEndings] & [other._MorphoFormEndings] are equals
            if (count != tempBufferHS.Count)
            {
                _morphoFormEndings = new char *[tempBufferHS.Count];
                fixed(char **morphoFormEndingsBase = _morphoFormEndings)
                {
                    var it = tempBufferHS.GetEnumerator();

                    for (var i = 0; it.MoveNext(); i++)
                    {
                        *(morphoFormEndingsBase + i) = (char *)it.Current;
                    }
                }
            }
            tempBufferHS.Clear();
        }
예제 #2
0
        internal void SetMorphoForms(List <MorphoFormNative> morphoForms)
        {
            if (morphoForms.Count != 0)
            {
                LinkedList <MorphoAttributeEnum> morphoAttributes = null;
                for (int i = 0, len = morphoForms.Count; i < len; i++)
                {
                    var morphoForm = morphoForms[i];

                    tempBufferHS.Add((IntPtr)morphoForm.Ending);

                    var endingUpperPtr = (IntPtr)morphoForm.EndingUpper;
                    if (!tempBufferDict.TryGetValue(endingUpperPtr, ref morphoAttributes))
                    {
                        morphoAttributes = PopLinkedList();
                        tempBufferDict.Add(endingUpperPtr, morphoAttributes);
                    }
                    var morphoAttribute = MorphoAttributePair.GetMorphoAttribute(this, morphoForm);
                    morphoAttributes.AddLast(morphoAttribute);
                }

                _morphoFormEndings = new char *[tempBufferHS.Count];
                fixed(char **morphoFormEndingsBase = _morphoFormEndings)
                {
                    var it = tempBufferHS.GetEnumerator();

                    for (var i = 0; it.MoveNext(); i++)
                    {
                        *(morphoFormEndingsBase + i) = (char *)it.Current;
                    }
                }

                tempBufferHS.Clear();

                _morphoFormEndingUpperAndMorphoAttributes = new MorphoFormEndingUpperAndMorphoAttribute[tempBufferDict.Count];

                var it2 = tempBufferDict.GetEnumerator();
                for (var i = 0; it2.MoveNext(); i++)
                {
                    _morphoFormEndingUpperAndMorphoAttributes[i] =
                        new MorphoFormEndingUpperAndMorphoAttribute(it2.Current_IntPtr, it2.Current_Value);
                    PushLinkedList(it2.Current_Value);
                }

                tempBufferDict.Clear();
            }
            else
            {
                _morphoFormEndings = EMPTY_ENDINGS;
                _morphoFormEndingUpperAndMorphoAttributes = EMPTY_MFUEMA;
            }
        }