start() 개인적인 메소드

private start ( int size ) : int
size int
리턴 int
예제 #1
0
파일: List.cs 프로젝트: syatanic/fantom
        public void eachRange(Range r, Func f)
        {
            int s = r.start(m_size);
            int e = r.end(m_size);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }

            if (f.arity() == 1)
            {
                for (int i = s; i <= e; ++i)
                {
                    f.call(m_values[i]);
                }
            }
            else
            {
                for (int i = s; i <= e; ++i)
                {
                    f.call(m_values[i], i);
                }
            }
        }
예제 #2
0
        public static long random(Range r)
        {
            rand.GetBytes(randBytes);
            long v = BitConverter.ToInt64(randBytes, 0);

            if (r == null)
            {
                return(v);
            }
            if (v < 0)
            {
                v = -v;
            }
            long start = r.start();
            long end   = r.end();

            if (r.inclusive())
            {
                ++end;
            }
            if (end <= start)
            {
                throw ArgErr.make("Range end < start: " + r).val;
            }
            return(start + (v % (end - start)));
        }
예제 #3
0
파일: List.cs 프로젝트: syatanic/fantom
        public List removeRange(Range r)
        {
            modify();
            int s = r.start(m_size);
            int e = r.end(m_size);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }

            int shift = m_size - s - n;

            if (shift > 0)
            {
                Array.Copy(m_values, s + n, m_values, s, shift);
            }
            m_size -= n;
            for (int i = m_size; i < m_size + n; ++i)
            {
                m_values[i] = null;
            }
            return(this);
        }
예제 #4
0
파일: StrBuf.cs 프로젝트: syatanic/fantom
        public StrBuf removeRange(Range r)
        {
            int s = r.start(sb.Length);
            int e = r.end(sb.Length);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }
            sb.Remove(s, n);
            return(this);
        }
예제 #5
0
        public static string getRange(string self, Range r)
        {
            int size = self.Length;

            int s = r.start(size);
            int e = r.end(size);

            if (e + 1 < s)
            {
                throw IndexErr.make(r).val;
            }

            return(self.Substring(s, (e - s) + 1));
        }
예제 #6
0
파일: StrBuf.cs 프로젝트: syatanic/fantom
        public string getRange(Range r)
        {
            int size = sb.Length;

            int s = r.start(size);
            int e = r.end(size);

            if (e + 1 < s)
            {
                throw IndexErr.make(r).val;
            }

            return(sb.ToString().Substring(s, (e - s) + 1));
        }
예제 #7
0
파일: Buf.cs 프로젝트: syatanic/fantom
        public Buf getRange(Range range)
        {
            long size = getSize();
            long s    = range.start(size);
            long e    = range.end(size);
            int  n    = (int)(e - s + 1);

            if (n < 0)
            {
                throw IndexErr.make(range).val;
            }

            byte[] slice = new byte[n];
            getBytes(s, slice, 0, n);

            Buf result = new MemBuf(slice, n);

            result.charset(charset());
            return(result);
        }
예제 #8
0
파일: List.cs 프로젝트: syatanic/fantom
        public List getRange(Range r)
        {
            try
            {
                int s = r.start(m_size);
                int e = r.end(m_size);
                int n = e - s + 1;
                if (n < 0)
                {
                    throw IndexErr.make(r).val;
                }

                List acc = new List(m_of, n);
                acc.m_size = n;
                Array.Copy(m_values, s, acc.m_values, 0, n);
                return(acc);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw IndexErr.make(r).val;
            }
        }
예제 #9
0
파일: Buf.cs 프로젝트: nomit007/f4
        public Buf getRange(Range range)
        {
            long size = getSize();
              long s = range.start(size);
              long e = range.end(size);
              int n = (int)(e - s + 1);
              if (n < 0) throw IndexErr.make(range).val;

              byte[] slice = new byte[n];
              getBytes(s, slice, 0, n);

              Buf result = new MemBuf(slice, n);
              result.charset(charset());
              return result;
        }
예제 #10
0
파일: StrBuf.cs 프로젝트: xored/f4
 public StrBuf replaceRange(Range r, string str)
 {
     int s = r.start(sb.Length);
       int e = r.end(sb.Length);
       int n = e - s + 1;
       if (n < 0) throw IndexErr.make(r).val;
       sb.Remove(s, n);
       sb.Insert(s, str);
       return this;
 }
예제 #11
0
파일: StrBuf.cs 프로젝트: xored/f4
        public string getRange(Range r)
        {
            int size = sb.Length;

              int s = r.start(size);
              int e = r.end(size);
              if (e+1 < s) throw IndexErr.make(r).val;

              return sb.ToString().Substring(s, (e-s)+1);
        }
예제 #12
0
파일: List.cs 프로젝트: xored/f4
        public List removeRange(Range r)
        {
            modify();
              int s = r.start(m_size);
              int e = r.end(m_size);
              int n = e - s + 1;
              if (n < 0) throw IndexErr.make(r).val;

              int shift = m_size-s-n;
              if (shift > 0) Array.Copy(m_values, s+n, m_values, s, shift);
              m_size -= n;
              for (int i=m_size; i<m_size+n; ++i) m_values[i] = null;
              return this;
        }
예제 #13
0
파일: List.cs 프로젝트: xored/f4
        public List getRange(Range r)
        {
            try
              {
            int s = r.start(m_size);
            int e = r.end(m_size);
            int n = e - s + 1;
            if (n < 0) throw IndexErr.make(r).val;

            List acc = new List(m_of, n);
            acc.m_size = n;
            Array.Copy(m_values, s, acc.m_values, 0, n);
            return acc;
              }
              catch (ArgumentOutOfRangeException)
              {
            throw IndexErr.make(r).val;
              }
        }
예제 #14
0
파일: List.cs 프로젝트: xored/f4
        public void eachRange(Range r, Func f)
        {
            int s = r.start(m_size);
              int e = r.end(m_size);
              int n = e - s + 1;
              if (n < 0) throw IndexErr.make(r).val;

              if (f.arity() == 1)
              {
            for (int i=s; i<=e; ++i)
              f.call(m_values[i]);
              }
              else
              {
            for (int i=s; i<=e; ++i)
              f.call(m_values[i], i);
              }
        }
예제 #15
0
파일: FanStr.cs 프로젝트: xored/f4
        public static string getRange(string self, Range r)
        {
            int size = self.Length;

              int s = r.start(size);
              int e = r.end(size);
              if (e+1 < s) throw IndexErr.make(r).val;

              return self.Substring(s, (e-s)+1);
        }
예제 #16
0
파일: Uri.cs 프로젝트: xored/f4
        private Uri slice(Range range, bool forcePathAbs)
        {
            if (m_pathStr == null)
            throw Err.make("Uri has no path: " + this).val;

              int size = m_path.sz();
              int s = range.start(size);
              int e = range.end(size);
              int n = e - s + 1;
              if (n < 0) throw IndexErr.make(range).val;

              bool head = (s == 0);
              bool tail = (e == size-1);
              if (head && tail && (!forcePathAbs || isPathAbs())) return this;

              Sections t = new Sections();
              t.path = m_path.getRange(range);

              StringBuilder sb = new StringBuilder(m_pathStr.Length);
              if ((head && isPathAbs()) || forcePathAbs) sb.Append('/');
              for (int i=0; i<t.path.sz(); ++i)
              {
            if (i > 0) sb.Append('/');
            sb.Append(t.path.get(i));
              }
              if (t.path.sz() > 0 && (!tail || isDir())) sb.Append('/');
              t.pathStr = sb.ToString();

              if (head)
              {
            t.scheme   = m_scheme;
            t.userInfo = m_userInfo;
            t.host     = m_host;
            t.port     = m_port;
              }

              if (tail)
              {
            t.queryStr = m_queryStr;
            t.query    = m_query;
            t.frag     = m_frag;
              }
              else
              {
            t.query    = emptyQuery();
              }

              if (!head && !tail)
              {
            t.str = t.pathStr;
              }

              return new Uri(t);
        }
예제 #17
0
파일: FanInt.cs 프로젝트: nomit007/f4
 public static long random(Range r)
 {
     rand.GetBytes(randBytes);
       long v = BitConverter.ToInt64(randBytes, 0);
       if (r == null) return v;
       if (v < 0) v = -v;
       long start = r.start();
       long end   = r.end();
       if (r.inclusive()) ++end;
       if (end <= start) throw ArgErr.make("Range end < start: " + r).val;
       return start + (v % (end-start));
 }