Questions tagged [sequence]

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence. In a relational database, a sequence is an object that is used to generate unique numbers for a primary key.

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence.

Sometimes, sequence is used as a generic name for both list, array and set for convenience.

In a , a sequence is an object that is used to generate unique numbers for a .

5959 questions
38
votes
1 answer

PostgreSQL gapless sequences

I'm moving from MySql to Postgres, and I noticed that when you delete rows from MySql, the unique ids for those rows are re-used when you make new ones. With Postgres, if you create rows, and delete them, the unique ids are not used again. Is there…
fatfrog
  • 2,118
  • 1
  • 23
  • 46
38
votes
4 answers

MappedSuperclass - Change SequenceGenerator in Subclass

I'm using JPA2 with Hibernate and try to introduce a common base class for my entities. So far it looks like that: @MappedSuperclass public abstract class BaseEntity { @Id private Long id; @Override public int hashCode() { …
atamanroman
  • 11,607
  • 7
  • 57
  • 81
36
votes
9 answers

hibernate oracle sequence produces large gap

I am using hibernate 3 , oracle 10g. I have a table: subject. The definition is here CREATE TABLE SUBJECT ( SUBJECT_ID NUMBER (10), FNAME VARCHAR2(30) not null, LNAME VARCHAR2(30) not null, EMAILADR VARCHAR2 (40), …
sse
  • 1,151
  • 2
  • 14
  • 26
36
votes
13 answers

How to reduce consecutive integers in an array to hyphenated range expressions?

In JavaScript, how can I convert a sequence of numbers in an array to a range of numbers? In other words, I want to express consecutive occurring integers (no gaps) as hyphenated ranges. [2,3,4,5,10,18,19,20] would become…
gokul
  • 361
  • 1
  • 3
  • 3
34
votes
10 answers

get next sequence value from database using hibernate

I have an entity that has an NON-ID field that must be set from a sequence. Currently, I fetch for the first value of the sequence, store it on the client's side, and compute from that value. However, I'm looking for a "better" way of doing this. I…
iliaden
  • 3,791
  • 8
  • 38
  • 50
34
votes
4 answers

Container of fixed dynamic size

Is there a standard container for a sequence of fixed length, where that length is determined at runtime. Preferrably, I'd like to pass an argument to the constructor of each sequence element, and use that argument to initialize a const member (or a…
MvG
  • 57,380
  • 22
  • 148
  • 276
33
votes
5 answers

Using Enumerable.Aggregate(...) Method over an empty sequence

I would like to use the Enumerable.Aggregate(...) method to concatenate a list of strings separated by a semicolon. Rather easy, isn't it? Considering the following: private const string LISTSEPARATOR = "; "; album.OrderedTracks is…
lorcan
  • 359
  • 1
  • 3
  • 4
32
votes
4 answers

Sequence find function?

How do I find an object in a sequence satisfying a particular criterion? List comprehension and filter go through the entire list. Is the only alternative a handmade loop? mylist = [10, 2, 20, 5, 50] find(mylist, lambda x:x>10) # Returns 20
Salil
  • 9,534
  • 9
  • 42
  • 56
32
votes
5 answers

Specifying distinct sequence per table in Hibernate on subclasses

Is there a way to specify distinct sequences for each table in Hibernate, if the ID is defined on a mapped superclass? All entities in our application extend a superclass called DataObject like this: @MappedSuperclass public abstract class…
gutch
  • 6,959
  • 3
  • 36
  • 53
32
votes
8 answers

Convert Python sequence to NumPy array, filling missing values

The implicit conversion of a Python sequence of variable-length lists into a NumPy array cause the array to be of type object. v = [[1], [1, 2]] np.array(v) >>> array([[1], [1, 2]], dtype=object) Trying to force another type will cause an…
Marco Ancona
  • 2,073
  • 3
  • 22
  • 37
31
votes
10 answers

Best way to determine if a sequence is in another sequence?

This is a generalization of the "string contains substring" problem to (more) arbitrary types. Given an sequence (such as a list or tuple), what's the best way of determining whether another sequence is inside it? As a bonus, it should return the…
Gregg Lind
  • 20,690
  • 15
  • 67
  • 81
31
votes
2 answers

Using Stride in Swift 2.0

I'm trying to figure out how to use the Stride features in Swift. It seems to have changed again, since Xcode 7.0 beta 6. Previously I could use let strideAmount = stride(from: 0, to: items.count, by: splitSize) let sets = strideAmount.map({…
DogCoffee
  • 19,820
  • 10
  • 87
  • 120
30
votes
3 answers

TCP Sequence Number

I'm trying to understand how the sequence numbers of the TCP header are generated. In some places I read that it is the "index of the first byte in the packet" (link here), on some other sites it is a random 32bit generated number that is then…
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77
29
votes
17 answers

Arrays - Find missing numbers in a Sequence

I'm trying to find an easy way to loop (iterate) over an array to find all the missing numbers in a sequence, the array will look a bit like the one below. var numArray = [0189459, 0189460, 0189461, 0189463, 0189465]; For the array above I would…
Mark Walters
  • 12,060
  • 6
  • 33
  • 48
28
votes
16 answers

Generating an alphabetic sequence in Java

I'm looking for a way of generating an alphabetic sequence: A, B, C, ..., Z, AA, AB, AC, ..., ZZ. Can anyone suggest a convenient way of doing this. What data structures can I make use of? I'd like methods which get the next code in the sequence…
mip
  • 1,886
  • 8
  • 26
  • 32