Пример #1
0
        private static Item findFromFront(Relation relation, float num)
        {
            Item item = relation.getHead();

            while (item != null && num > Utterance.getSegmentEnd(item))
            {
                item = item.getNext();
            }
            return(item);
        }
Пример #2
0
        private static Item findFromEnd(Relation relation, float num)
        {
            Item item = relation.getTail();

            while (item != null && Utterance.getSegmentEnd(item) > num)
            {
                item = item.getPrevious();
            }
            if (item != relation.getTail())
            {
                item = item.getNext();
            }
            return(item);
        }
Пример #3
0
        private static Item getItem(Relation relation, float num)
        {
            Item  tail       = relation.getTail();
            float segmentEnd = Utterance.getSegmentEnd(tail);

            if (num < 0f || segmentEnd < num)
            {
                return(null);
            }
            if (segmentEnd - num > num)
            {
                return(Utterance.findFromFront(relation, num));
            }
            return(Utterance.findFromEnd(relation, num));
        }